JQuery $. post $. ajax usage

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.