其他分享
首页 > 其他分享> > android – 无法读取null的属性’documentElement’

android – 无法读取null的属性’documentElement’

作者:互联网

从Phonegap Android应用程序调用Web服务时,我收到此错误.

01-13 23:49:52.219: E/Web Console(529): Uncaught TypeError: Cannot read property ‘documentElement’ of null at file:///android_asset/www/soapclient.js:158

这是相关代码:

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

解决方法:

它可能是因为跨域请求,CORS
所以要么你必须把它包括在你的heades中

Accept: Access-Control-Allow-Origin

或者也使用

chrome.exe --disable-web-security

或者您也可以安装chrome扩展

Enable cors request extention in chrome

希望它会有所帮助.

标签:android,android-emulator,cordova,soap-client
来源: https://codeday.me/bug/20190709/1416968.html