Home > front end >  XMLHTTP. The responseText
XMLHTTP. The responseText

Time:03-19

The front-end code



<meta charset="utf-8" & gt;
<script>

The function test () {
//////////////////////////////////return XMLHTTP responseText and output
Var y=loadXMLDoc ();
Alert (y);
//////////////////////////////////output XMLHTTP responseText
Document. The getElementById (" myDiv "). The innerHTML=y;

}
The function loadXMLDoc ()
{
Var XMLHTTP;
If (window. The XMLHttpRequest)
{
//IE7 +, Firefox, Chrome, Opera, Safari execute code
xmlhttp=new XMLHttpRequest();
}
The else
{
//IE6, IE5 browser code execution
XMLHTTP=new ActiveXObject (" Microsoft. XMLHTTP ");
}
XMLHTTP. Onreadystatechange=function ()
{
If (XMLHTTP. ReadyState==4 & amp; & XMLHTTP. Status==200)
{
//the document. The getElementById (" myDiv "). The innerHTML=XMLHTTP. The responseText;

//////////////////output XMLHTTP responseText
Alert (XMLHTTP. The responseText);
Xx=XMLHTTP var. The responseText;
//////////////////return XMLHTTP responseText
The return of xx;

}
}
XMLHTTP. Open (" POST ", "ajax_test_return_value. PHP", true);
XMLHTTP. The send ();
}
</script>

<body>







The back-end code
<? PHP
Echo "123";
?>

My question is how to return XMLHTTP. The responseText value is 123,
or back-end PHP how to send an array to receive front-end ajax and as a return value passed to the test function of the variable y thank you very much!
  •  Tags:  
  • Ajax
  • Related