日期:2014-05-18  浏览次数:20399 次

初学问题,高手帮忙看看
WebForm1.aspx
的一段脚本如下
xmlHTTP.open( "GET ", "WebForm2.aspx ",true);
if(xmlHTTP.readyState==4)
  alert(xmlHTTP.ResponseText);
  xmlHTTP.send(null);

WebForm2.aspx
中只有一句
Response.Write( " <input   type= 'text '   width= '200px '> ");

怎么什么都没有返回
请问差什么代码帮忙补一下

------解决方案--------------------
function ajaxComplete()
{
if(xmlhttp.readyState == 4 )
{
//dosomething
}
}
function ajaxrequest( url )
{
xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP ");
//你该这样关联处理函数来实现回调,而非直接写在下面,直接写在下面的话,open里用false
xmlhttp.onreadystatechange=ajaxComplete;
xmlhttp.open( "GET ", url, true);
xmlhttp.send();
}
------解决方案--------------------
你没有指定返回的处理函数!当然没有反映了!
<script language= "javascript ">
var xmlobj=false;
function send_request(url){
xmlobj=false;
xmlobj=new ActiveXObject( "Microsoft.XMLHTTP ");
xmlobj.onreadystatechange=data_Deal;
xmlobj.open( "GET ",url,true);
xmlobj.send(null);
}

function data_Deal(){
if(ht.readyState==4){
if(ht.status==200){
document.write(xmlobj.responseText); //获取返回值
}
else{
alert(xmlobj.status)
}
}
}

</script>