Sending data via AJAX

前端 未结 1 1689
遇见更好的自我
遇见更好的自我 2020-12-11 11:28

i have a build a javascript which does following: Get content via ajax->php->sql and show it on index.php after clicking the content there will be shown new content.

相关标签:
1条回答
  • 2020-12-11 12:21

    You can send data to the callback script, specified in the URL, by including values in the jQuery.ajax data setting. Depending on what type of request you're making, this data will either be included in the $_GET or $_POST global variables. For example, to POST data to your callback script, you could do:

    $.ajax({                    
      url: 'content/get.php',     
      type: 'post', // performing a POST request
      data : {
        data1 : 'value' // will be accessible in $_POST['data1']
      },
      dataType: 'json',                   
      success: function(data)         
      {
        // etc...
      } 
    });
    

    For more information, please read up on the jQuery.ajax function's documentation at https://api.jquery.com/jQuery.ajax/

    0 讨论(0)
提交回复
热议问题