Ajax in jquery

Source: Internet
Author: User

I. Load method

Only part of the Northern California document is shown, you can add a space after the URL and a jquery selector, and when the URL is loaded, jquery uses the specified selector to select the part to display from the loaded HTML

// load and display the weather forecast for the temperature section $ ("#temp"). Load ("weather_report.html #temperature");

In addition to the required URL parameters. The load () method also accepts two optional parameters

// load the weather forecast for a specific area code of $ ("#temp"). Load ("weather_report.html", "zipcode=02134"); // use the object as data and specify the Fahrenheit temperature of $ ("#temp"). Load ("weather_report.html", {zipcode:02134,units: ' F '});

Another parameter to load is the callback function, which invokes the callback function when the AJAX request succeeds or fails, and if no data is specified, the callback function can be passed in as the second argument, otherwise it must be the third argument

Two. Jquery.ajax ()

Jquery.ajax ({   "get",       url:url,   null,   "script",   Success:callback    })

Common options in Jquery.ajax ()



Data: A string or an object that can be used to add a send. Usually the object is replaced with a string

DataType: Specifies the expected type of the data and how jquery handles the data, the legal value is "text,html,scrit,json,jsonp,xml", the option has no default value, and when not specified, jquery checks the corresponding Content-type header to determine how the returned data is processed

ContentType: Specifies the HTTP Content-type header for the request, which is "application/x-www-form-urlencoded" by default, and if Type:post needs to set this value (how can I not remember to set it?? ~!)

Timeout: Time-out, in milliseconds, if set, the request cancels the simultaneous error callback, the status code parameter in the callback is "timeout", the default time is 0, indicating that unless the parent is completed, the person will never cancel

Cache: A GET request, if set to False,jquery will add a "_=" parameter to the URL, or replace the already existing parameter with the same name, the value is the current time, you can disable browser-based caching, because each request of the URL is different



Ajax in jquery

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.