Learning Note 12JS Asynchronous request

Source: Internet
Author: User

* Generally use JS to monitor button events, should first listen to the page onload event.

Where the *js is written, it will be executed where the page is parsed.

Asynchronous request: The so-called asynchronous request, is to use JS to monitor the button click event, and send the request, wait until the reply, then use JS to page jump, or dynamically change the page.
Use cases: When the request is ashx, you can use the Async method, the page does not need to brush to a blank page of ashx or not for the display of the page.

* Send asynchronous requests using jquery:
$ ("#按钮ID"). Click (Fuction () {
$.get (
"Page Url.ashx",
"a=1&b=2",//can be converted to JSON object here, [id:123,name: "SSS"]
Fuction (data) {
callback function
}

);

});

* Asynchronous use of $.getjson can send request JSON data to the background, the background must send a JSON-compliant string.

* Most complete asynchronous request settings, $.ajax
$.ajax
(
{
URL: "Xxx.ashx",
data:{}
}
)

Learning Note 12JS Asynchronous request

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.