$.ajax () Method--Ajax functions in very fast Rui

Source: Internet
Author: User
Tags script tag string format

The Ajax () function and those of the ABS () function sin () are the bottom-up implementations, packaged, and ready to be used directly.

The user only needs to pass in the parameters, and then they can get the corresponding results.

$.ajax ({name:value, Name:value, ...})  The parameters are:{name:value, Name:value, ...} Just like a JSON string

Common parameter names:

Instance: $.ajax ({url: "/jquery/test1.txt", Async:false})

1. URL properties: The requested address is requested as a parameter of type string, (default is the current page address). 2. Type: A parameter of type string is required, and the request method (post or get) defaults to get. Note Other HTTP request methods, such as put and delete, can also be used, but only some browsers support it. 4. Async: Requires a parameter of type Boolean, which is set to True by default and all requests are asynchronous requests. If you need to send a synchronization request, set this option to false. Note that the synchronization request locks the browser, and the user's other actions must wait for the request to complete before it can be executed. 6. Data: A parameter that is required to be an object or string that is sent to the server. If it is not already a string, it is automatically converted to a string format. The GET request will be appended to the URL. To prevent this automatic conversion, you can view the ProcessData option. Object must be a key/value format, for example {foo1:"bar1", Foo2:"bar2"Convert to &foo1=bar1&foo2=bar2. In the case of arrays, jquery automatically corresponds to the same name for different values. For example {foo:["bar1","bar2"]} to &foo=bar1&foo=bar2. 7. DataType: Requires a parameter of type string that expects the data type returned by the server. If not specified, jquery automatically returns Responsexml or ResponseText based on the HTTP packet mime information and is passed as a callback function parameter. The available types are: xml: Returns an XML document that can be processed with jquery. HTML: Returns plain text HTML information, and the included script tag is executed when the DOM is inserted. Script: Returns plain text JavaScript code. Results are not automatically cached. Unless the cache parameter is set. Note When you make a remote request (not under the same domain), all post requests are converted to get requests. JSON: Returns the JSON data. JSONP:JSONP format. When a function is called using the Sonp form, for example Myurl? Callback=?,jquery will automatically replace the latter one "?"for the correct function name to execute the callback function. Text: Returns a plain text string. Ten. Success: A callback function called after a successful request for a function type parameter has two parameters. (1) is returned by the server and processed according to the datatype parameter. (2A string that describes the status. function (data, textstatus) {//data may be xmldoc, jsonobj, HTML, text, and so on             This;//options parameters passed when calling this Ajax request         } One. Error: A function that requires a parameter of type function, which is called when the request fails. The function has 3 parameters, the XMLHttpRequest object, the error message, and optionally the error object being captured. The Ajax event functions are as follows: function (XMLHttpRequest, textstatus, Errorthrown) {//normally textstatus and Errorthrown only one of them contains information           This;//options parameters passed when calling this Ajax request}

Links: http://www.cnblogs.com/yeer/archive/2009/07/23/1529460.html

$.ajax () Method--Ajax functions in very fast Rui

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.