Jquery AJAX $. post $. get usage

Source: Internet
Author: User

Jquery code ajax

Jquery. post ("newdoajax. asp tutorial x", {max: 'n! ', Name: 'wsenmin'}, function (data) {alert (data )});
Jquery. get ("newdoajax. aspx", {max: 'B! ', Name: 'wsenmin'}, function (data) {alert (data )});
Var superman = "max = I am jq & name = it is ajax ";
Jquery. ajax ({
Type: "post ",
Url: "newdoajax. aspx ",
Data: superman,
Success: function (msg) {alert (msg );}
});

Asp.net tutorial

<% @ Page language = "c #" validaterequest = "false" enablesessionstate = "true" %>
<% @ Import namespace = "system. data. sqlclient" %>
<% @ Import namespace = "system. data" %>
<% @ Import namespace = "system. configuration" %>
<% @ Import namespace = "system. web. security" %>
<% @ Import namespace = "system. drawing" %>
<Script type = "text/c #" runat = "server">
Protected void page_loadcomplete (object sender, eventargs e)
{
Response. clearcontent ();
Response. clear ();
String yy = null;
Int count = request. form. count;
Int count2 = request. querystring. count;
Foreach (var cv in request. form)
{
Yy + = cv + ":" + request. form [cv. tostring ()]. tostring () + "Ha is simple | ";
}
Foreach (var cv in request. querystring)
{
Yy + = cv + ":" + request. querystring [cv. tostring ()]. tostring () + "easy to use. Wow | ";
}
Response. write (yy. substring (0, yy. length-4 ));
Response. end ();
}
</Script>

 

$. Ajax () is the underlying ajax Implementation of jquery. For easy-to-use high-level implementation, see $. get, $. post, and so on.

There are several ajax event parameters: beforesend, success, complete, and error. We can define these events to process every ajax request.

$. Ajax ({url: 'stat. php tutorial ',

Type: 'post ',

Data: {name: "keyun "},

Datatype: 'html ',

Timeout: 1000,

Error: function () {alert ('error loading php document ');},

Success: function (result) {alert (result );}

});

Asp. aspx page code

Response. contenttype = "application/Webpage effects on"; response. write ("{result: '" + request ["name"] + ", hello! (This message comes from the server) '} "); jquery code:
$. Post ("ajax. aspx ", {action:" post ", name:" lulu "}, function (data, textstatus) {// data can be xmldoc, jsonobj, html, text, and so on. // this; // configure the options for this ajax request. For more information, see jquery. this alert (data. result) ;}, "json ");

 

Jquery. post (url, [daTa], [callback], [type]): uses the post method for asynchronous requests.
Parameters:
Url (string): the url of the request.
DaTa (map): (optional) data to be sent to the server, expressed in key/value pairs.
Callback (function): (optional) callback function when the load is successful (this method is called only when the response returns success ).
Type (string): (optional) the official description is: type of daTa to be sent. In fact, it should be the client request type (json, xml, and so on)
This is a simple post Request function to replace complex $. ajax. You can call the callback function when the request is successful. If you need to execute the function when an error occurs

 

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.