ASP. NET + jquery. Ajax details 3-$. Get and $. Post

Source: Internet
Author: User

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 !)

 

 

Jquery. Get (URL, [data], [callback], [type])

Load information through remote http get requests

 

Parameter --

URL: the requested URL.

Data: Key/value parameter to be sent.

Callback: callback function when the load is successful.

Type: The returned content format is XML, HTML, script, JSON, text, and _ default.

 

The get () method provides the callback function, which has three parameters: responsetext, textstatus, and XMLHttpRequest, which respectively represent the content, Request status, and XMLHttpRequest objects returned by the request.

 

$. Get ("Data/getserviceinfo. aspx ", function (responsetext, textstatus, XMLHttpRequest) {// responsetext: Content returned by the request // textstatus: Request status: Success, error, notmodified, timeout // XMLHttpRequest: XMLHTTPRequest object });

 

Datatype specifies the expected server response data type. By default, jquery performs intelligent judgment. Possible types: "XML" "html" "text" "script" "JSON" "jsonp"

The biggest difference between jquery. Post and jquery. get is that the former loads information through remote http post requests. The latter loads information through a remote http get request. The other parts are basically the same.

 

Instance:

Client --

<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "jqueryajaxgetpost. aspx. cs" inherits = "jqueryajaxtest. jqueryajaxget" %> <! 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 --

 

Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; namespace jqueryajaxtest. data {public partial class getmethodinfo: system. web. UI. page {protected void page_load (Object sender, eventargs e) {string Param = ""; // obtain the parameter if (! String. isnullorempty (httpcontext. current. request ["Param"]) {Param = httpcontext. current. request ["Param"];} // clear the Buffer Response. clear (); // write the string to the response output stream response. write ("HTTP Request Method:" + request. httpmethod. toupper () + "; the passed parameter is:" + PARAM); // the client that sends all the current buffered outputs and stops this page from executing response. end ();}}}

 

Add:

 

Compare load and get:

 

$. Load () is the simplest way to get data from the server. It is almost equivalent to $. Get (). The difference is that it is not a global function and it has an implicit callback function. When a response is detected successfully (for example, when textstatus is "success" or "notmodified"), $. Load () sets the HTML content of the matching element to the returned data.

 

This is why $ ("# result"). Load () is used in the previous instance (). In this example, $. Get () is used ()

 

The end of article 1 will be followed by Article 1

 

 

 

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.