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