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