Directory (updated articles will be connected, and an article will be updated every two to three days starting from March 13, July 25 ):
ASP. NET + jquery. Ajax details 1-opening section (published on February 25)
ASP. NET + jquery. Ajax details 2-$. Load (published on 2012.07.26)
ASP. NET + jquery. Ajax details 3-$. Get and $. Post (published on February 30)
ASP. NET + jquery. Ajax details 4-$. getjson (published on February 31)
ASP. NET + jquery. Ajax details 5-$. getscript (2012.08.04)
ASP. NET + jquery. Ajax details 6-$. ajaxsetup (2012.08.06)
ASP. NET + jquery. Ajax details 7-Global Ajax events (published on 2012.08.09)
ASP. NET + jquery. Ajax details 8-core $. Ajax (published on February 12)
ASP. NET + jquery. Ajax details 9-serialize and serializearray (February 15)
ASP. NET + jquery. Ajax detailed description: 10-json and XML + are written at the end of the article (published on February 20 !)
The serialize () method creates a URL encoded text string by serializing the form value. You can select one or more form elements (such as input and/or text boxes) or Form elements. Serialized values can be used in URL query strings when an Ajax request is generated. For example, when Ajax is used, it is often necessary to assemble the input data in the form of 'name = Xiaoming & sex = 1'. The serialize method of jquery can be used to complete this work easily.
Serializearray () serializes form elements
(Similar to the '. serialize ()' method. This method returns a JSON object instead of a JSON string. You need to use plug-ins or third-party libraries for string-based operations.
Jquery. JSON plugin (Click here to download)
Using serializearray () with the $. tojson method, we can easily obtain the json of the form object and convert it to a JSON string.
Client code:
<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "jqueryserialize. aspx. cs" inherits = "jqueryajaxtest. jqueryserialize" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">
Server code:
Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; namespace jqueryajaxtest {public partial class submitform: system. web. UI. page {protected void page_load (Object sender, eventargs e) {string single = httpcontext. current. request ["single"]; string TXT = httpcontext. current. request ["TXT"]; string hid = httpcontext. current. request ["hid"]; string txtarea = httpcontext. current. request ["txtarea"]; string check = httpcontext. current. request ["check"]; string radio = httpcontext. current. request ["radio"]; response. clear (); response. write ("the form key-Value Pair received by the server is: </BR>" + "Single/" + single + "," + "TXT/" + TXT + ", "+" hid/"+ hid +", "+" txtarea/"+ txtarea +", "+" check/"+ check + ", "+" Radio/"+ radio); response. end ();}}}
Note: The tag name cannot use the JS keyword. Otherwise, a conflict may occur, leading to empty returned data.
This section mentions JSON many times. If you are confused about the JSON object, don't worry. next section will compare and analyze JSON and XML.