服务器 XMLHttp 导致 IE 8 中的页面永远执行?
我从名为 Error1.asp 的页面中获取了以下代码。但每当它运行时,发布数据的页面永远不会显示。需要显示的是“default1.aspx”,但它永远不会在 IE8 中呈现。在 Firefox 和 Chrome 中,它使用如下相同的代码进行渲染,没有任何问题。 我怎样才能让这个 ServerXMLHttp 在 IE 8 中工作?我的电脑上有 Win 7 64 位。
Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","http://localhost/ClassicASPErrorHandling/default1.aspx",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send "errorDesc=" & Server.HTMLEncode(Server.GetLastError().Description() )& "&errorDetailedDesc=" & Server.HTMLEncode(Server.GetLastError().ASPDescription()) & "&errorURL=" & strURL & "&errorLineNumber=" & Server.HTMLEncode(ASPErr.Line()) & "&errorFile=" & Server.HTMLEncode( ASPErr.File()) & "&errorSource=" & Server.HTMLEncode(ASPErr.Source()) & "&logonUser=" & strLogonUser & "&errorCode=" & Server.HTMLEncode(Server.GetLastError().ASPCode() )
Response.Write xmlhttp.responseText
Response.ContentType = "text/xml"
Response.Write xmlhttp.responsexml.xml
Set xmlhttp = nothing
I have the following code from a page called Error1.asp. But whenever it runs, the page to which data is posted never shows up. What needs to show up is 'default1.aspx' but it never renders in IE8. In Firefox and Chrome it does render without any issues using the same code as below.
How can I make this ServerXMLHttp work in IE 8? I have Win 7 64-bit on my computer.
Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","http://localhost/ClassicASPErrorHandling/default1.aspx",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send "errorDesc=" & Server.HTMLEncode(Server.GetLastError().Description() )& "&errorDetailedDesc=" & Server.HTMLEncode(Server.GetLastError().ASPDescription()) & "&errorURL=" & strURL & "&errorLineNumber=" & Server.HTMLEncode(ASPErr.Line()) & "&errorFile=" & Server.HTMLEncode( ASPErr.File()) & "&errorSource=" & Server.HTMLEncode(ASPErr.Source()) & "&logonUser=" & strLogonUser & "&errorCode=" & Server.HTMLEncode(Server.GetLastError().ASPCode() )
Response.Write xmlhttp.responseText
Response.ContentType = "text/xml"
Response.Write xmlhttp.responsexml.xml
Set xmlhttp = nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案已经被接受,但是为了其他读者的利益,这里的代码应该是这样的:-
An answer has already been accepted however for the benefit of other readers here is what the code should look like:-
我怀疑这是一个浏览器问题,我认为发生的情况是您在页面上显示内容,然后更改内容类型,IE 可能无法理解这一点,因此,在您的代码中尝试此更改,看看它是否有效:
如果您尝试在
ContentType = "text/xml"
页面上显示非 XML 数据,我可以向您保证 IE 可能是第一个出现问题的浏览器。确保写入页面的唯一内容是 XML 或更改ContentType = "text/html"
I doubt this is a browser issue, i think what is happening is you are displaying content on the page, then changing the content type, IE may be having trouble understanding this, therefore, try this change in your code and see if it works out:
And if you're trying to display NON-XML data on a
ContentType = "text/xml"
page, i can assure you IE would probably be the first browser that would give issues. Make sure the only content written to the page is XML or change yourContentType = "text/html"