① Load ()
$. Load (url, data, callback)
- The url of the page to be loaded,
- Data key/value format sent to the server,
- Callback indicates the callback function that is returned to the page after loading successfully.
The url can also filter page elements.
<script type="text/javascript">"#Button1").click( () { $( "#divTip").load("a.html .aa" ); </script>
A.html code:
<div class="clsShow">test</div><div class="clsShow aa">test1</div>
Html:
<Script type = "text/javascript"> "# Button1 "). click ("news. js ", html =" "+ = (index + 1 + =" title: "+ item. title + "<br/>" + = "Date:" + item. date + "<br/>" "# divTip" </script>
③ GetScript ()
$. GetScript (url, callback): Get the js file and automatically execute the injection script.
Parameter: url is the js file address to be loaded, and callback is the callback function.
Instance:
News1.js:
Data = "title": "The New tianlong Babu is about to stop broadcasting" "date": "2014-1-26" "title": "Who do you like as a singer" "date ": "2014-1-24" html = "" + = (index + 1 + = "title:" + item. title + "<br/>" + = "Date:" + item. date + "<br/>" "# divTip"
Call:
$("#Button1").click("news1.js"
① Method
- $. Get (url, [data], [callback], [type])
- $. Post (url, [data], [callback], [type])
Parameter description: The url indicates the data address to be requested, the data indicates that the address sent to the server is in the key/value format, and the callback indicates the callback function executed after the request is successful; type is the format of the returned data, such as html, json, and xml.
NOTE: If data contains a Chinese format, use the encodeURI () method for transcoding. When receiving data from the client, use the decodeURI () method for decoding.
② Difference:
The $. get and $. post methods are slightly different. The main differences are as follows:
- $. Get is not suitable for transferring data with a large amount of data. $. post does not have this restriction.
- $. Get request results are cached in the browser, while $. post results are not cached in the browser.
③ Instance:
<script type="text/javascript">"#Button1").click(() { $.get("UserInfo.aspx""#txtName""#divTip" .html(data); </script>
① Method
$. Ajax ([options]) is a relatively underlying asynchronous call method. The options parameter is in the key/value format and contains both the settings for sending requests and the corresponding callback data.
Note that the Jsonp method is used for cross-origin calls.