JQuery $.post $.ajax Usage
Jquery.post(URL, [data], [callback], [type]): Use post to make asynchronous requests
Parameters:
URL (String): The URL address of the sending request.
Data (MAP): (optional) data to be sent to the server, expressed as a Key/value key-value pair.
Callback (function): (optional) The callback function when loading succeeds (the method is called only if the return state of response is success).
type (String): (optional) The official description is: Type of data to be 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. The callback function can be called when the request succeeds. If you need to execute the function on error, use $.ajax. Example code:
Ajax.aspx:
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
For the option configuration information for this AJAX request, please refer to the Jquery.get () mentioned in this
alert (Data.result); }, "JSON");
Click Submit:
The format of the request is "JSON":
$.ajax () This is the underlying AJAX implementation of jquery. Easy to use high-level implementation see $.get, $.post and so on.
Here are a few Ajax event parameters:
Beforesend,
Success,
Complete , error. We can define these events to handle each of our AJAX requests well.
$.ajax ({
URL: ' stat.php ',
Type: ' POST ',
Data:{name: "Keyun"},
DataType: ' HTML ',
timeout:1000,
Error:function () {alert (' Error loading PHP document ');},
Success:function (Result) {alert (result);}
});
Add by Q at 2008.11.25
A little problem with the post of jquery today
Because you want to delete it in bulk, start by looping the post to that URL, and then refresh this page
There's a problem here.
$ ("input[@name = ' Qa_checkbox ']"). each (function ()
{
if ($ (this). attr (' checked ') = = undefined)
{
}
Else
{
$.post (url,{action: "POST"},function (data) {alert (data); Window.location.reload ();}, "text");
}
})
You can only delete the first piece of data if you use it.
$ ("input[@name = ' Qa_checkbox ']"). each (function ()
{
if ($ (this). attr (' checked ') = = undefined)
{
}
Else
{
$.post (url+$ (This). Val (), {Action: "POST"},function (data) {alert (data);}, "text");
}
})
Window.location.reload ();
In this case, although it can be deleted, you can also refresh this page, it seems that reload is in the post function before the operation, but post will be error, the reason for study;
Finally thought of a compromise.
$ ("input[@name = ' Qa_checkbox ']"). each (function ()
{
if ($ (this). attr (' checked ') = = undefined)
{
}
Else
{
url = URL + $ (this). Val () + ' _ ';
}
})
$.post (url,{action: "POST"},function (data) {alert (data); Window.location.reload ();}, "text");
}
String the ID to be deleted, use a post processing, put the reload in the function of the post there is no problem
JQuery $.post $.ajax Usage