【问题标题】:Cannot read property 'documentElement' of null无法读取 null 的属性“documentElement”
【发布时间】:2012-01-14 03:57:36
【问题描述】:

我在从 Phonegap Android 应用调用 Web 服务时收到此错误。

01-13 23:49:52.219:E/Web 控制台 (529):未捕获的类型错误:无法在 file:///android_asset/www/soapclient.js:158 处读取 null 的属性“documentElement”

以下是相关代码:

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

【问题讨论】:

  • 从错误中看起来 wsdl.documentElementnull。所以检查wsdl是如何设置的,如果它有属性documentElement

标签: android android-emulator cordova soap-client


【解决方案1】:

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

Accept: Access-Control-Allow-Origin

或者也使用

chrome.exe --disable-web-security

或者你也可以安装 chrome 扩展

Enable cors request extention in chrome

希望它会有所帮助。

【讨论】:

    猜你喜欢
    • 2015-02-13
    • 2016-11-30
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多