<! Doctype HTML public "-// W 3c // 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>ExploitationXMLHTTPAdd data without refreshing</Title>
<SCRIPT type = "text/JavaScript">
<! --
Function adddatapost (suserid, susername)
{
VaR objxmlhttp = new activexobject ("Microsoft. XMLHTTP ");
// Suserid = escape (suserid );
// Susername = escape (susername );
VaR userinfo = "userid =" + suserid + "& username =" + susername;
Objxmlhttp. Open ("Post", "ajax_output.php", false );
//The sending header needs to be defined.
Objxmlhttp. setRequestHeader ("Content-Length", userinfo. length)
Objxmlhttp. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ")
Objxmlhttp. Send (userinfo)
//Clear input data
Document. All. userid. value = "";
Document. All. username. value = "";
Alert (objxmlhttp. responsetext );
Document. getelementbyid ("XXXX"). innerhtml=Objxmlhttp. responsetext;
}
// -->
</SCRIPT>
</Head>
<Body>
<Input type = "text" name = "userid"> <br>
<Input type = "text" name = "username"> <br>
<Input type = "button" onclick = "adddatapost (document. All. userid. Value, document. All. username. Value)" value = "addddata">
</Body>
</Html>
<?
Echo $ _ post ['userid'];
Echo $ _ post ['username'];
?>
<Script language = "JavaScript">
VaR XMLHTTP;
Function sendcall (URL, Params ){
If (window. activexobject ){
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
} Else if (window. XMLHttpRequest ){
XMLHTTP = new XMLHttpRequest ();
}
XMLHTTP. onreadystatechange = callback;
XMLHTTP. Open ('post', URL, true );
XMLHTTP. setRequestHeader ("Content-Length", Params. Length );
XMLHTTP. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded ');
XMLHTTP. setRequestHeader ("connection", "close ");
XMLHTTP. Send (Params );
}
Function callback (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
Document. getelementbyid ("title"). innerhtml = XMLHTTP. responsetext;
}
}
}
Function submitmsgform (){
VaR Cycler = Document. getelementbyid ("Cycler"). value;
VaR Title = Document. getelementbyid ("title"). value;
VaR content = Document. getelementbyid ("content"). value;
VaR Params = "receiver =" + receiver + "& Title =" + title + "& content =" + content;
VaR url = "ajax_output.php ";
Sendcall (URL, Params );
}
</SCRIPT>
<Form name = "form" Action = "" method = "Post">
<Div id = "XXXX"> </div>
<Table>
<Tr>
<TD> receiver </TD>
<TD> <input type = "text" name = "er Er" id = "receiver"> </TD>
</Tr>
<Tr>
<TD> title </TD>
<TD> <input type = "text" name = "title" id = "title"> </TD>
</Tr>
<Tr>
<TD> content </TD>
<TD> <input type = "text" name = "content" id = "content"> </TD>
</Tr>
<Tr>
<TD> </TD>
<TD> <input type = "button" name = "Submit" value = "Submit" onclick = "submitmsgform ()"> </TD>
</Tr>
</Table>
</Form>
<?
$ Cycler = $ _ post ['cycler'];
$ Title = $ _ post ['title'];
$ Content = $ _ post ['content'];
$ Content = $ author er. $ title. $ content;
Echo $ content;
?>