创建XMLHttpRequest时出错 [英] error creating XMLHttpRequest

查看:127
本文介绍了创建XMLHttpRequest时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为用户解决一个问题,我无法b / b再现或解释。这里希望其他人可能会有相同的经历。

我尝试使用progids创建XMLHTTP对象两次尝试

Msxml2.XMLHTTP和(如果失败)Microsoft.XMLHTTP。如果后者

失败,我会显示错误。出现的错误是NULL。是

undefined"。我还在等待确切的浏览器

版本的确认,但截图我看起来像IE5.5,标题栏中的公司

信息表示它''是一个定制的安装。

我完全没有关于这个的想法 - 在这个上下文中没有点击谷歌

这个错误消息。


谢谢

Hi, I''m trying to solve a problem for a user which I can neither
reproduce or explain. Here goes in the hope that someone else may have
experienced the same.
I make two attempts to create the XMLHTTP object, using the progids
"Msxml2.XMLHTTP" and (if that fails) "Microsoft.XMLHTTP". If the latter
fails I display the error. The error appearing is ""NULL" is
undefined". I''m still awaiting confirmation of the exact browser
version, but the screenshot I have looks like IE5.5, and the company
info in the titlebar indicates that it''s a customised install.
I''m completely out of ideas on this one - no hits whatsoever in google
for this error message in this context.

thanks

推荐答案

steveH写道:
我做了两次尝试使用progids
Msxml2.XMLHTTP创建XMLHTTP对象。和(如果失败)Microsoft.XMLHTTP。如果
后者失败,我会显示错误。出现的错误是NULL。
undefined"。
I make two attempts to create the XMLHTTP object, using the progids
"Msxml2.XMLHTTP" and (if that fails) "Microsoft.XMLHTTP". If the
latter fails I display the error. The error appearing is ""NULL" is
undefined".




你能发布你的代码吗?没有看到你的代码就不可能猜到问题是什么?



这是从我的Ajax工具箱创建对象的一个​​例子:


/ **

*返回XMLHttpRequest对象,作为核心对象或ActiveX

*实现。如果一个对象无法实例化,它将返回null;

* /

AjaxRequest.getXmlHttpRequest = function(){

if(window。 XMLHttpRequest){

返回新的XMLHttpRequest();

}

else if(window.ActiveXObject){

//基于 http://jibbering.com/2002/4/httprequest。 HTML

/ * @ cc_on @ * /

/ * @ if(@_jscript_version> = 5)

try {

返回新的ActiveXObject(" Msxml2.XMLHTTP");

} catch(e){

try {

返回新的ActiveXObject(" Microsoft.XMLHTTP");

} catch(E){

返回null;

}

}

@end @ * /

}

else {

返回null;

}

};

-

Matt Kruse
http://www.JavascriptTo olbox.com
http://www.AjaxToolbox.com



Can you post your code? It''s impossible to guess at what the problem is
without seeing your code :)

This is an example of creating the object from my Ajax Toolbox:

/**
* Returns an XMLHttpRequest object, either as a core object or an ActiveX
* implementation. If an object cannot be instantiated, it will return null;
*/
AjaxRequest.getXmlHttpRequest = function() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// Based on http://jibbering.com/2002/4/httprequest.html
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
return null;
}
}
@end @*/
}
else {
return null;
}
};
--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com





steveH写道:



steveH wrote:

我做了两次尝试使用progids
Msxml2.XMLHTTP创建XMLHTTP对象。和(如果失败)Microsoft.XMLHTTP。如果后者失败,我会显示错误。出现的错误是NULL。是
未定义的。我还在等待确切的浏览器
版本的确认,但截图我看起来像IE5.5,标题栏中的公司
信息表明它是自定义安装。
I make two attempts to create the XMLHTTP object, using the progids
"Msxml2.XMLHTTP" and (if that fails) "Microsoft.XMLHTTP". If the latter
fails I display the error. The error appearing is ""NULL" is
undefined". I''m still awaiting confirmation of the exact browser
version, but the screenshot I have looks like IE5.5, and the company
info in the titlebar indicates that it''s a customised install.




我们需要查看你的代码。

可以在IE中为区域禁用ActiveX,这样可以是一个

导致问题。

-


Martin Honnen
http://javaScript.FAQTs.com/


感谢您的回复,这里''代码


尝试{

var o = new ActiveXObject(" Msxml2.XMLHTTP");

return o;

}

catch(e){

try {

var o = new ActiveXObject(" Microsoft。 XMLHTTP");

返回o;

}

catch(e){

errDialogShow("错误在计算器,,无法创建

XMLHTTP \\ n \"" + e.message +" \"");

返回null;

}

}

适用于绝大多数用户,适用于IE6& IE5.5(这个

来自工厂对象,另一个对象共创建FireFox

对象)。对于问题情况,显示错误消息(标题)

计算器错误 (消息)无法创建XMLHTTPNULL是

undefined"。我所做的任何尝试禁用activex / uninstall XMLHTTP到/ b $ b尝试重现错误只会导致预期的消息

无法创建XMLHTTP自动化服务器无法创建对象

Thanks for the replys, here''s the code

try {
var o = new ActiveXObject("Msxml2.XMLHTTP");
return o;
}
catch (e){
try {
var o = new ActiveXObject("Microsoft.XMLHTTP");
return o;
}
catch(e){
errDialogShow("Error in Calculator","Unable to create
XMLHTTP\n\""+e.message + "\"");
return null;
}
}
works for the vast majority of users, works for me in IE6 & IE5.5 (this
is from a factory object, a different object altogether creates FireFox
object). For the problem case, the error message displays (Title)
"Error in Calculator" (Message) Unable to create XMLHTTP "NULL" is
undefined". Any attempt I make to disable activex/uninstall XMLHTTP to
try and reproduce the error just results in the expected message
"Unable to create XMLHTTP Automation server cannot create object"


这篇关于创建XMLHttpRequest时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆