Home > front end >  JQuery asynchronous ajx in summary
JQuery asynchronous ajx in summary

Time:09-20

JQuery asynchronous ajx to summarize
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Development tools and key technology: Adobe Dreamweaver JavaScript
Author: wen-jian tang
Writing time: on May 3, 2020,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
JQ form submission of the form submission is than JS code quantity a lot less
Prevents the form automatically submit method column: onsubmit="return false. (written in form the start tag)
JQ form access method

JS form access methods:

Two chart compares JQ is obviously convenient than JS,
The ajax method in the Jq:
Write $. In the function of ajax this method some methods in brackets is the keyword,
Type: this is to write you to with what method, such as the Type: "post", (in JQ later also can't be used when writing code; )
Url: the title of the name of the controller method,
DataType: expect the server returns the data type of the, if not specified, the jQuery automatically according to the HTTP packet MIME information intelligent judgment,
We use the json format, can be set to "json"
Async: general default Settings with asynchronous is asynchronous can carve it into a synchronous it is good to write options to false if you want to write is asynchronous can ignore this
Data: is written to submit the form data,
Success: it is a way, after the success of the request of the callback function, the incoming data after the return, and a string containing success code
Error: is a method and request failure is call this function, the incoming XMLHttpRequest object
Form serialization serialize (), so we can instead of string concatenation
Column: var serData=https://bbs.csdn.net/topics/$(" # myform "). The serialize ();
The form is submitted in the JQ methods:


In JQ getJSON method and posJSON
The getJSON method as shown in figure:

Unlike the ajax this method need not write type and to join in brackets, such as json,
If you want to use this way to write in the controller: return Json (STR, JsonRequestBehavior. AllowGet);
$. GetJSON () method can only accept the return value for the json data
  • Related