Javascript代码在chrome和Firefox上给出错误

Javascript Code giving error on chrome and firefox

本文关键字:出错 错误 Firefox 代码 chrome Javascript      更新时间:2023-09-26

我在代码中使用了以下行来使用 javascript 使用 Web 服务

var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;

上面的JavaScript代码在IE和Safari上运行良好,但在Chrome和Firefox上,它在控制台上抛出错误:

XMLHttpRequest cannot load http://192.168.50.141:4323/HelloWorld.asmx?wsdl. Origin null is not allowed by Access-Control-Allow-Origin.
Uncaught TypeError: Cannot read property 'documentElement' of null 

请帮忙

提前致谢

如果您使用命令行运行 chrome

喜欢

chrome.exe --disable-web-security

这是我在开发时使用的

相关文章: