ASP.NET2.0运用Ajax返回数据写入<div id="HText"></div>中提示ID:HText未定义···
ASP.NET2.0运用Ajax返回数据写入 <div id= "HText "> </div> 中用HText.innerHTML
提示ID:HText未定义···郁闷都搞一上午了,没搞定~
请高手看看问题在哪里?谢谢。
========================================================================
<head>
<title> No Fresh Paging </title>
<script language= "javascript " type= "text/javascript ">
var IAjax=null;
function GetInfoList()
{
IAjax=new ActiveXObject( "Msxml2.XMLHTTP ");
IAjax.onreadystatechange=HandleStateChange;
IAjax.open( "POST ", "Handler.ashx ",true);
IAjax.send(null);
}
function HandleStateChange()
{
if(IAjax.readyState==4)
{
if(IAjax.status==200)
{
alert(IAjax.responseText);
HText.innerHTML=IAjax.responseText;
}
}
}
</script>
</head>
<body>
<div>
<script language= "javascript " type= "text/javascript ">
GetInfoList();
</script>
</div>
<div id= "HText ">
</div>
</body>
[解决办法]
<div id= "HText ">
</div>
<script language= "javascript " type= "text/javascript ">
GetInfoList();
</script>
位置这样放
[解决办法]
document.getElementById( "HText ").innerHTML = IAjax.responseText;
[解决办法]
var a = document.getElementById( "HText ")
a.innerHTML=IAjax.responseText;
[解决办法]
<script language= "javascript " type= "text/javascript "> 改成
<script language= "javascript " type= "text/javascript " defer> 看看呢
[解决办法]
是不是 引号"里面有"引号
[解决办法]
<body onload= "GetInfoList() ">
<div>
</div>
<div id= "HText ">
</div>
</body>
[解决办法]
HText放在js前面