JQuery. post(Url, [data], [callback], [type]): Use the POST method for asynchronous requests.
Parameters:
Url(String): the URL of the request.
Data(Map): (optional) data to be sent to the server, expressed in Key/value pairs.
Callback(Function): (optional) callback Function when loading is successful (this method is called only when the Response returns success ).
Type(String): (optional) the official description is: Type of data to be sent. In fact, it should be the client request type (JSON, XML, and so on)
This is a simple POST Request function to replace complex $. ajax. You can call the callback function when the request is successful. To execute a function when an error occurs, use $. ajax. Sample Code:
Ajax. aspx:
JQuery code:
Click to submit:
The request format is set to "json ":
$. Ajax () is the underlying AJAX Implementation of jQuery. For easy-to-use high-level implementation, see $. get, $. post, and so on.
Here are several Ajax event parameters:
BeforeSend,
Success,
Complete, error.We can define these events to process every Ajax request.
Url:
Type:
Data: {Name:
DataType:
Timeout:
Error:
Success:
});
Today I encountered a small problem with jquery post.
Because batch deletion is required, we start to use the cyclic post to the url and refresh the page.
This causes a problem.
{
{
}
{
$. Post (url, {Action:
}
})
In this case, only the first data item can be deleted;
{
{
}
{
$. Post (url
}
})
Window. location. reload ();
If this is used, you can delete it and refresh the page. It seems that reload runs before the post function, but the post will report an error. The reason remains to be studied;
Finally, I figured out a compromise.
{
{
}
{
Url
}
})
$. Post (url, {Action :}
Concatenate the id to be deleted into a string, use post processing, and put reload in the post function.