<! 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>
<SCRIPT type = "text/JavaScript">
VaR XMLHTTP;
Function createxmlhttprequest (){
If (window. activexobject ){
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest ){
XMLHTTP = new XMLHttpRequest ();
}
}
Function refreshmodellist (){
VaR url = "ajaxpost. aspx"
VaR query = "pid = 11 & toid = 1395493964 & content =" + urlencode ("test ");
Createxmlhttprequest ();
XMLHTTP. onreadystatechange = handlestatechange;
XMLHTTP. Open ("Post", URL, true );
XMLHTTP. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
XMLHTTP. Send (query );
}
Function handlestatechange (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
Updatemodelslist ();
}
}
}
Function updatemodelslist (){
VaR make = Document. getelementbyid ("make ");
VaR Results = XMLHTTP. responsetext;
Make. innerhtml = results;
}
</SCRIPT>
<Title> ajaxpost test </title>
</Head>
<Body>
<Div id = "make"> </div> <br>
<Input type = "button" value = "obtain Info" onclick = "refreshmodellist ()">
</Body>
</Html>
<Script language = "VBScript">
Function str2asc (strstr)
Str2asc = hex (ASC (strstr ))
End Function
Function asc2str (ascasc)
Asc2str = CHR (ascasc)
End Function
</SCRIPT>
<Script language = "JavaScript">
/* Urlencode and urldecode functions at the beginning */
Function urlencode (STR ){
VaR ret = "";
VaR strspecial = "! \ "# $ % & '() * +,/:; <=>? [] ^ '{| }~ % ";
VaR TT = "";
For (VAR I = 0; I <Str. length; I ++ ){
VaR CHR = Str. charat (I );
VaR c = str2asc (CHR );
Tt + = CHR + ":" + C + "N ";
If (parseint ("0x" + C)> 0x7f ){
RET + = "%" + C. Slice (0, 2) + "%" + C. Slice (-2 );
} Else {
If (CHR = "")
RET + = "+ ";
Else if (strspecial. indexof (CHR )! =-1)
RET + = "%" + C. tostring (16 );
Else
RET + = CHR;
}
}
Return ret;
}
Function urldecode (STR ){
VaR ret = "";
For (VAR I = 0; I <Str. length; I ++ ){
VaR CHR = Str. charat (I );
If (CHR = "+ "){
RET + = "";
} Else if (CHR = "% "){
VaR ASC = Str. substring (I + 1, I + 3 );
If (parseint ("0x" + ASC)> 0x7f ){
RET + = asc2str (parseint ("0x" + ASC + Str. substring (I + 4, I + 6 )));
I + = 5;
} Else {
RET + = asc2str (parseint ("0x" + ASC ));
I + = 2;
}
} Else {
RET + = CHR;
}
}
Return ret;
}
</SCRIPT>