When jquery 1.5 is released, it adds a method Jquery.when (). You can handle multiple AJAX requests at a time. See the jquery API documentation for more details.
Collection by Ancker
Jquery.post (URL, [data], [callback], [Type]): Asynchronous request using POST method
Parameters:
URL (String): The URL address where the request is sent.
Data (MAP): (optional) The information to be sent to the server, expressed as a Key/value key-value pair.
Callback (function): (optional) the callback function (which is invoked only if the response return state is success) when loading succeeds.
Type (String): (optional) The official description is: type of data to is sent. The type that should actually be requested for the client (Json,xml, etc.)
This is a simple POST request function to replace the complex $.ajax. Callback functions can be invoked when the request succeeds. If you need to perform a function when an error occurs, use $.ajax. Sample code:
ajax.asp Tutorial x:
Response.ContentType = "Application/json";
Response.Write ("{result: '" + request["Name"] + ", Hello! (This message comes from the server) '} ');
JQuery Code:
$.post ("Ajax.aspx", {Action: "Post", Name: "Lulu"},
function (data, textstatus) {
Data can be xmldoc, jsonobj, HTML, text, and so on.
This This AJAX request option configuration information, please refer to Jquery.get ().
alert (Data.result);
}, "JSON");
$ (document). Ready (function () {
$ (' #getsetgo '). Click (function () {
$.when ($.ajax ("page1.php tutorial"), $.ajax ("do.php"). Done (function (A1, A2) {
$ (' #id1 '). html (a1[0]);
$ (' #id2 '). html (a2[0]);
});
});
});
jquery Another way to handle multiple AJAX requests on the same page
$.post (
"Do.php",
{
Type: ' 1 '
},
function (data, textstatus)
{
},
"JSON");
$.post (
"Dosysthfile.aspx",
{
Type: ' 2 '
},
function (data, textstatus)
{
},
"JSON");
Simple to handle in PHP
if ($_request[' type '])
{
Echo 1;exit;
}
echo 0;