JQuery AJAX call (1) -- load and pass data, jqueryajax

Source: Internet
Author: User
Tags getscript

JQuery AJAX call (1) -- load and pass data, jqueryajax



I. load Method asynchronously requests data

Use the load () method to load data in the server through Ajax requests and place the returned data in the specified element. The call format is as follows:

Load (url, [data], [callback])

The url of the parameter is the address of the loading server. The data parameter can be set to the data sent during the request. The callback parameter is the callback function executed after the data request is successful.







2. Use the getJSON () method to asynchronously load JSON data


Using the getJSON () method, you can use Ajax asynchronous requests to obtain the arrays on the server and parse the obtained data. The results are displayed on the page. The call format is as follows:


JQuery. getJSON (url, [data], [callback]) or $. getJSON (url, [data], [callback])


Here, the url parameter is the server address for loading the json format file. The data parameter is the data sent during the request, and the callback parameter is the callback function executed after the data request is successful.








3. Use the getScript () method to asynchronously load and execute js files


The getScript () method is used to asynchronously request and execute JavaScript files in the server. The Calling format is as follows:


JQuery. getScript (url, [callback]) or $. getScript (url, [callback])


The parameter url is the server request address. The callback parameter is the callback function executed after the request is successful.





4. get data from the server using the GET () method


When the get () method is used, the GET method is used to request data from the server, and the request data is returned through the callback function parameters in the method. The call format is as follows:


$. Get (url, [callback])


The parameter url is the server request address. The callback parameter is the callback function executed after the request is successful.








5. Use the post () method to send data from the server in POST Mode


Compared with the get () method, the post () method is mostly used to send data to the server in POST mode. After the server receives the data, it processes the data and returns the processing result to the page, the call format is as follows:


$. Post (url, [data], [callback])


The parameter url is the server request address. The optional data is the data sent when a request is sent to the server. The optional callback parameter is the callback function executed after the request is successful.

 














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.