jquery Ajax Application Instance code
/*
Ajax sends data to a page
$.post (' save.cgi ', {
Text: ' My string ',
Number:23
}, function () {
Alert (' Your data has been saved. ');
});
If you do need to write some complex Ajax scripts, you need to use the $.ajax () function. You can specify that XML, script, HTML, or json,jquery will automatically prepare the appropriate results for the callback function so that you can use the result immediately. You can also specify Beforesend, error, success, or complete callback functions to provide users with more feedback about the Ajax experience. In addition, there are other parameters available that you can use to set the timeout for Ajax requests, or to set the status of the page "last modified"
*/
Super Simple jquery Ajax application
function Visit_build () {
var myclasses = new Ajax (' Visit!build.action ', {
Method: ' Post ',
data:{
Id:this_bid
},
Oncomplete:function (response) {
}
). request ();
}
Here is a validation mailbox address mailbox Authentication instance with multiple parameters
function Nactactivity_submit () {
var aid = $ (' aid '). Value;
var name = $ (' a_name '). Value;
var mobile = $ (' mobile '). Value;
var email = $ (' email '). Value;
var address = $ (' address '). Value;
var email_p =/^ ([a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + (. [ A-za-z0-9_-]) +/;
var tel_p =/^[0-9-]+$/;
if (name.length>0 && mobile.length==11 && email.length>0 && email_p.test (email) & & Tel_p.test (MOBILE)) {
var myclasses = new Ajax (' Activity!submitnact.action ', {
Method: ' Post ',
data:{
Id:aid,
Name:name,
Mobile:mobile,
Email:email,
Address:address
},
Oncomplete:function (response) {
$ (' Massage_box '). sethtml (response);
$ (' Massage_box '). SetStyle (' width ', 810);
$ (' Massage_box '). SetStyle (' height ', 500);
$ (' Massage_box '). SetStyle (' visibility ', ' visible ');
$ (' mask '). SetStyle (' visibility ', ' visible ');
$ (' Massage_box '). SetStyle (' left ', (980-a+200)/2);
$ (' Massage_box '). SetStyle (' Top ', (window.screen.height-650)/2);
}
). request ();
}else{
Alert (' Please fill in complete, name, mobile phone number, mailbox are required ');
}
}
/*
Working with XML documents
$.ajax () makes Ajax simpler by complexity
$.ajax ({
URL: ' Document.xml ',
Type: ' Get ',
DataType: ' xml ',
timeout:1000,
Error:function () {
Alert (' Error loading XML document ');
},
Success:function (XML) {
Do something with XML
}
});
When the success callback function returns an XML document, you can use jquery to retrieve the XML document in the same way that it retrieves an HTML document. This makes it fairly easy to process XML documents and integrates content and data into your Web site