Using the Ajax () method to load server data

Source: Internet
Author: User

The use of the ajax() method is the lowest, most powerful method of requesting server data, it can not only get the data returned by the server, but also send a request to the server and pass a numeric value, its invocation format is as follows:

jQuery.ajax([settings])Or$.ajax([settings])

Where the parameter settings is the configuration object when the AJAX request is sent, in which the URL represents the path requested by the server, data is passed at the request, datatype is the data type returned by the server, success is the callback function for the successful execution of the request, Type is the way to send data requests by default to get.

For example, clicking the "Load" button in the page calls the ajax() method to request the server to load a TXT file and displays the contents of the returned file in the page, as shown in:

Effects displayed in the browser:

As you can see, when the "Load" button is clicked, the calling $.ajax() method requests the TXT file on the server, invokes the success callback function when the request succeeds, obtains the returned data, and displays it in the page.

Using the Ajax () method to load server data

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.