Asynchronous Data submission using JavaScript (Ajax) (original)
Source: Internet
Author: User
Using JavaScript for asynchronous data submission is much more efficient than directly using the ready-made Ajax control (I have only used ajax.net)
The experiment found that large data could be submitted-about 40 kb of Experiment
Function dosubmit ()
{
.......
VaR urlparameter = "cfg =" + urlpara1
+ "& Type =" + vkeytype
+ "& Starttime =" + vstarttime
+ "& Endtime =" + vendtime
+ "& Subject =" + vsubject;
// Alert (vsubject );
// Return;
If (typeof XMLHttpRequest! = 'Undefined ')
{
Httprequest3 = new XMLHttpRequest ();
}
Else if (typeof activexobject! = 'Undefined ')
{
Httprequest3 = new activexobject ('Microsoft. xmlhttp ');
}
If (httprequest3)
{
Httprequest3.open ('post', "/background page. aspx", true); // true is asynchronous
Httprequest3.setrequestheader ('content-type', 'application/X-WWW-form-urlencoded ');
Httprequest3.onreadystatechange = oncomplete;
Httprequest3.send (urlparameter );
}
Currentpage = N;
Return;
}
Function oncomplete ()
{
If (4 = httprequest3.readystate)
{
// Alert (httprequest3.responsetext );
If (200 = httprequest3.status)
{
VaR rettext = httprequest3.responsetext;
Document. getelementbyid ("mainlist"). innerhtml = rettext;
}
}
}
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