jQuery encapsulated ajax


$.get(url [,data] [,fn callback function] [, dataType]);

  • data: The data passed to the server, request string and json object can be set

  • fn: callback function, this function is called after the ajax request is completed, you can use this function Complete the subsequent processing of ajax

  • dataType: The server returns the data type, html, text, xml, json

Note: The ajax It is an asynchronous get request


##$.post(url[,data][,fn callback function][, dataType]);

  • This method is exactly the same as the $.get() method. The difference is that it is a post request.


$.ajax({ //json object

url: request address,

data: data passed to the server ,

dataType: Data returned from the server in the format of html, text, xml, json

type:get/post request method

success:function(){} ajax successful request The final callback function can be used for subsequent processing using

async:[true] asynchronous/false synchronous,

cache:[true] cache/false not cached,

} )

   php.cn     

ajax请求

  1. php content is:


  2. $name, 'age'=>$age ); echo json_encode($arr); ?>
Note: You can copy these two files locally and put them in one Folder for testing


Continuing Learning
||
php.cn

ajax请求

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!