0
Q:

jquery ajax json

$.ajax({
  method: "POST",
  url: "some.php",
  dataType: "json",
  data: {}
}).done(json => console.log(json));
2
  <head>
      <title>The jQuery Example</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
           
            $("#driver").click(function(event){
               $.getJSON('result.json', function(jd) {
                  $('#stage').html('<p> Name: ' + jd.name + '</p>');
                  $('#stage').append('<p>Age : ' + jd.age+ '</p>');
                  $('#stage').append('<p> Sex: ' + jd.sex+ '</p>');
               });
            });
               
         });
      </script>
   </head>
   
   <body>
   
      <p>Click on the button to load result.html file:</p>
       
      <div id = "stage" style = "background-color:#cc0;">
         STAGE
      </div>
       
      <input type = "button" id = "driver" value = "Load Data" />
       
   </body>
0
 $.ajax({

   url     : "file.php",
   method  : "POST",

       data: { 

         //key                      :   value 
         action                   	:   action , 
         key_1   					:   value_key_1,
         key_2   					:   value_key_2
       }
   })

   .fail(function() { return false; })

	// Appel OK
   .done(function(data) {

   console.log(data);

 });
11

New to Communities?

Join the community