Jquery is really not difficult ~ Sixth, the asynchronous call method in JQ ~ Continued

Source: Internet
Author: User
Tags getscript
ArticleDirectory
    • Parameters for sorted asynchronous requests are described as follows:
    • $. Load () loads remote HTML file code and inserts it into the DOM

Back to directory

The previous article mainly introduced how to Implement Asynchronous Data Access and operations through JQ, which is written in the most standard. Ajax complete form. This article mainly describes the remaining short form.

Parameters for sorted asynchronous requests are described as follows:
 
// $ Ajax asynchronous common parameter description. The parameters in [] can be omitted. // URL, [data], [callback], [type] // data: the key/value parameter to be sent. // Callback: callback function when loading is successful. // Type: returned content format, XML, HTML, script, JSON, 
$. Load () Load remote HTML files Code And insert it to the Dom.
 
//$. Load format//URL, [data, [callback]$ ("# Load"). Load ("ajaxdata.htm ");
$. Get () sends a GET request to the specified page
 
//$. Get format$. Get ("ajaxdata.htm ",Function(Data) {$ ("# Gets"Pai.html (data );},"Html ");
$. Getjson () Obtain the JSON object from the specified page
 
//$. Getjson format//URL, [data], [callback]$. Getjson ("IMG. js ",Function(JSON) {alert ("OK"); $ ("# Getjsons"). ATTR ({"src": JSON [0]. SRC, "Alt": JSON [0]. Alt });});
$. Getscript () loads the specified JS File
 
//$. Getscript format//URL, [callback]$. Getscript ("IMG. js ",Function() {Alert ("IMG. js loaded successfully! ")});
$. Post () sends a POST request to the specified page
 
//$. Post format//URL, [data], [callback], [type]$. Post ("test. ashx", {name: "John", time: "2 "});//Common Parameters$. Post ("test. ashx", $ ("# testform"). serialize ());//Form parameters (serialized form parameters, which are separated and used in implementation)
$. Serialize () serialize form elements
<  Form  >    <  Input  Type  = "Text"  Name  = "Name"  Value  = "Zzl"  />  <  Input  Type  = "Text"  Name = "Email"  Value  = "Bfyxzls@sina.com"  Checked  = "Checked"  />  <  Input  Type  = "Test"  Name  = "ADDR"  Value  = "Fangshan. Beijing"  Checked  = "Checked" />  </  Form  > 
 
Console. Log ($ ("form"). serialize ());
$. Serializearray () serializes table elements (similar to the '. serialize ()' method) and returns JSON data structure data.
 
Console. Log ($ ("form"). serialize ());

Result:

 
[{Name:'Name', value: 'zzl'}, {Name:'Email ', value: 'bfyxzls'}, {Name:'Addr ', value: 'fangshan. Beijing'}]

Well, the asynchronous JQ operations are similar here. Thank you very much for reading them!

Back to directory

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.