我正在尝试创建xml http请求对象,我无法找到我出错的地方,当我尝试提醒它打印错误的对象时
var xmlHttpObject = createXmlHttpRequestObject();
alert(xmlHttpObject); // return object is false is my problem
function createXmlHttpRequestObject() {
var xmlHttpObject;
//mozilla browser
if (window.ActiveXobject) {
try {
xmlHttpObject = new ActiveXobject("Microsoft.XMLHTTP");
alert(xmlHttpObject);
} catch (e) {
xmlHttpObject = false;
}
} else {
try {
xmlHttpObject = XMLHttpRequest();
alert('test'); //it is not coming in to the block itself
} catch (e) {
xmlHttpObject = false;
}
}
if (xmlHttpObject) {
alert("object created");
} else {
alert("object not created");
return xmlHttpObject;
}
}

答案 0 :(得分:0)
根本不这样做。我们现在有比XmlHttp更好的工具。
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://www.npmjs.com/package/isomorphic-fetch
答案 1 :(得分:0)
为了完整起见 - 这是考虑到
的脚本的更正版本window.ActiveXObject difference in IE11
<img src="@Url.Content("~/photos/image.jpg")">