jquery Basics (v) Ajax and Tool class functions __ large data

Source: Internet
Author: User
Tags getscript
ajax-load ()

Use the load () method to load the data from the server through an AJAX request and place the returned data in the specified element in the format: URL, network request address, data, optional parameter, callback, and the callback function after the request succeeds.

$.load (URL, [data], [callback]); Ajax-getjson ()

Using the Getjson () method to load the data in the server through an AJAX request, and parsing the server's data, calling in callback, its invocation format: for example, to obtain a person object, then the formal parameter data in callback is a person entity.

$.getjson (URL, [data], callback); Ajax-getscript ()

Use the Getscript () method to request the JS file in the server via Ajax, execute the JS code on the server in Calback, and its calling format:

$.getscript (URL, [data], [callback]); Ajax-get ()

The request data is requested from the server using a Get method, and the requested data is returned by the parameter of the callback function in the method, and its invocation format is:

$.get (URL, [callback]);

For example, the request is made to an address by a Get method, and the returned data JSON is processed and returned via callback:

$.get ("http://www.imooc.com/data/info_f.php", function (data) {
    //data.name
    //data.say
}, "JSON");
ajax-post ()

Post method to request server data, which is called in the following format:

$.post (URL, [data], [callback]);

To give a simple example:

$.post ("http://www.imooc.com/data/check_f.php", {
    name: "Qdl",
    age:25
}, function (data) {
    // Data.name
    //data.say
});
Ajax-ajax ()

It is the lowest-level, most powerful way to request server data, and its invocation format is:

$.ajax ([Settings]);

Let's introduce the settings configuration parameters: URL, the server path of the request, data, the parameters that are passed when the request is made, the dataType that the server returns, success, the callback when the request succeeds, type, the request method, the default get.

Let's take an example:

$.ajax ({
    URL: "http://www.imooc.com/data/check_f.php",
    data: {name: "Qdl"},
    DataType: "Text"
    , Success:function (data) {alert ("successful Request");},
    type: "POST"
});
Ajax-ajaxsetup ()

For example, all of our project requests are post, and the return data is in JSON format, and we simply call Ajaxsetup () once to set the global parameters. The calling format is the same as Ajax (). Ajax-ajaxstart () and Ajaxstop ()

The Ajaxstart () and Ajaxstop () methods are binding Ajax events. The Ajaxstart () method is used to trigger the function before the AJAX request is emitted, and the Ajaxstop () method is used to trigger the function after the AJAX request completes. They are called in the following format:

$ (selector). Ajaxstart (function ())

$ (selector). Ajaxstop (function ())

Executes the Ajaxstart () method-bound function before the AJAX request is sent, and executes the function bound by the Ajaxstop () method after the request succeeds. Tool class Functions

1. Get the name and version information of the browser

$.browser.chrome is true and is currently the Chrome browser, false or not.
$.browser.version Way to get version information.

2. Whether it belongs to the model of the box

$.support.boxmodel, true to, false not to belong to

3. Whether the object is empty

$.isemptyobject (obj);

4. Is the original object

$.isplainobject (obj);//ability to detect if an object is an original object created by {} or the new object () keyword

5. The inclusion relationship of the node

$.contains (Node_a, Node_b); node node_a contains node Node_b.
Related Article

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.