您只使用一个IE不支持的对象。之后 行而不是这个xmlHttp = GetXmlHttpObject();使用以下 var xmlHttp = false; if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { xmlHttp = new ActiveXObject(" Msxml2.XMLHTTP"); } 尝试这一个,你的问题必须解决。 感谢您的回复, 它没有解决我的问题,事情我需要将HTML页面响应放在< div>中使用id =" hema"的标签,我需要从registration.jsp获取html页面(这是我发送网址和确定响应的页面),其中我将其设为未定义在改变你建议的代码之后。在mozilla n IE中。 iam发布名为stateChanged()的函数::: 函数stateChanged(如果(xmlHttp.readyState == 4) { alert(xmlHttp.responseText) ; var response = xmlHttp.responseHTML; document.getElementById(" hema")。innerHTML = response; alert(xmlHttp。 responseText); alert(" Hi in state changed"); } } 能够在上面的函数中使用标签获取带有变量响应的html内容但是我无法将html放入div中,如上所述,我可以用什么方式显示html内容在响应中作为 html页面内< div id =" hema">, 等待4个建议.. thanq .. 试试这个: 展开 | 选择 | Wrap | 行号 hi ,Iam Nagesh,Begineer in using Ajax,welli have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tagiam able to get the response in the <div> tag in mozilla (im takingthe HTML response),<script>function confirm(){xmlHttp=GetXmlHttpObject();if (xmlHttp==null){alert ("Your browser does not support AJAX!");return;}var url="confirm.jsp";url=url+"?q="+document.login.id.value;//url=url+"&sid="+Math.random();url=url+"&p="+document.login.pwd.value;//url=url+"&pid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);}function stateChanged(){if (xmlHttp.readyState==4){ alert("hi");//var message = xmlHttp.responseXML.getElementsByTagName("message" )[0].childNodes[0].data;//alert(message); alert("everone"); alert(xmlHttp.responseText); var response=xmlHttp.responseText; document.getElementById("hema").innerHTML=response ; alert(xmlHttp.responseText); alert("Hi in state changed");}<script>and the form iam using in the <body> is<form name="login"><table align="center" ><tr><td><b>UserId:</b></td><td><input type="text" name="id"></td></tr><tr><td><b>Password</b></td><td><input type="password" name="pwd"></td></tr></table><div align="center"> <p><input type="button" value="Login" onclick="confirm()"></p></div><div> <p>For Registration Click Here <input type="button" value="Register" onclick="register()"></p></div><div id="hema"></div></form>so the issue is that i will get the html response in the script that should be displayed in the <div id="hema"> tag.It is working in mozilla but not in IE, any answers.., thanks 解决方案HiYou are using only one Object which is not supported By IE. afterLine instead of this xmlHttp=GetXmlHttpObject(); use following var xmlHttp= false;if (window.XMLHttpRequest){xmlHttp= new XMLHttpRequest();}else if (window.ActiveXObject){xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");}Try This One , your problem must be solved.Thanks for ur reply,well it didnt solve my problem ,the thing is i need to put the HTML page response in the <div> tag with id="hema",i need to get the html page from registration.jsp(this is the page to which im sending url and geting the response),where as i m getting it to be "undefined" after changing the code as u have suggested.in both mozilla n IE.,iam posting the function named stateChanged():::function stateChanged(){if (xmlHttp.readyState==4){ alert(xmlHttp.responseText); var response=xmlHttp.responseHTML; document.getElementById("hema").innerHTML=response ; alert(xmlHttp.responseText); alert("Hi in state changed");}}im able to get the html content with tags int he var response in the above function but im unable to put the html into the div as mentioned befor,what is the possible way in which i can display the html content in the response as thehtml page inside the <div id="hema">,waiting 4 suggestion..thanq..try this: Expand|Select|Wrap|Line Numbers 这篇关于使用< div>里面< form>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-01 10:06