Partial Ajax page call

Source: Internet
Author: User

<SCRIPT>
Function gb2utf8 (data ){
VaR glbencode = [];
Gb2utf8_data = data;
ExecScript ("gb2utf8_data = midb (gb2utf8_data, 1)", "VBScript ");
VaR T = escape (gb2utf8_data ). replace (/% u/g ,""). replace (/(. {2 })(. {2})/g, "%$ 2% $1 "). replace (/% ([A-Z].) % (. {2})/g, "@ $1 $2 ");
T = T. Split ("@");
VaR I = 0, j = T. length, K;
While (++ I <j ){
K = T [I]. substring (0, 4 );
If (! Glbencode [k]) {
Gb2utf8_char = eval ("0x" + k );
ExecScript ("gb2utf8_char = CHR (gb2utf8_char)", "VBScript ");
Glbencode [k] = escape (gb2utf8_char). substring (1, 6 );
}
T [I] = glbencode [k] + T [I]. substring (4 );
}
Gb2utf8_data = gb2utf8_char = NULL;
Return Unescape (T. Join ("% "));
}
Function ajaxsubmit2 (){
Document. getelementbyid ("loginstate"). innerhtml = "<center> </center> ";
// Create an XMLHTTPRequest object
VaR XMLHTTP;
Try {
XMLHTTP = new XMLHttpRequest ();
} Catch (e ){
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
}
XMLHTTP. onreadystatechange = function (){
If (4 = XMLHTTP. readystate ){
If (200 = XMLHTTP. Status ){
VaR content = gb2utf8 (XMLHTTP. responsebody );
Document. getelementbyid ("loginstate"). innerhtml = content;
} Else {
Alert ("error ");
}
}
}
// Open the connection. True indicates asynchronous submission.
XMLHTTP. Open ("Post", "Time. php? Id = 1 ", true );
// Set the HTTP header as follows when the method is post
XMLHTTP. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded ');
// Send data
XMLHTTP. Send (null );
}
</SCRIPT>
<! 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">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>

<Body>
<Div id = "loginstate"> </div>
<Script language = "JavaScript"> ajaxsubmit2 (); </SCRIPT>
</Body>
</Html>

 

Related Article

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.