【问题标题】:Error:"Unable to get property 'content' of undefined or null reference file错误:“无法获取未定义或空参考文件的属性‘内容’
【发布时间】:2014-05-25 07:19:02
【问题描述】:

我正在尝试使用 sharepoint web 服务、phoneGap 和 windows phone 8 获取数据。 当我测试下面的代码时,它给出了这个错误:

错误:“无法获取未定义或空引用文件的属性‘内容’:x-wmapp0:www/webs.html Line:1”

有什么帮助吗?

<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js" type="text/javascript"></script>
<script src="cordova-2.3.0.js" type="text/javascript"></script>
</head>
<body>
<div>
<script type="text/javascript">

    $(document).ready(function () {
        var soapEnv =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Comptes</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='WorkAddress' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";

        // Call web service
        $.ajax({
            url: "http://demo-crm.progedsolutions.com/sites/CRM/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,

            complete: processListAccessResult,
            contentType: "text/xml; charset=\"utf-8\"",
            success: function () {
                alert("success");
            },
            error: function () {
                alert("ERROR");
            },
        });
    });

    // Process result
    function processListAccessResult(xData, status) {
        $(xData.responseXML).find("z\\:row").each(function () {
            $("#data").append("<li>" + $(this).attr("ows_WorkAddress") + "</li>");
        });
    }

</script>

<ul id="data"></ul>
</div>

</body>
</html>

【问题讨论】:

标签: javascript jquery cordova windows-phone-8


【解决方案1】:

这可能是由于您包含的脚本中的版本冲突。确保cordova-2.3.0.js 可以与jquery-1.4.4.js 一起使用。

【讨论】:

    【解决方案2】:

    我知道这篇文章已经过时了但是我想帮助以防将来有人陷入其中。

    1 - 确保 deviceready 事件可用。

          document.addEventListener("deviceready", function () {   });
    

    2 - 忽略第一个错误,应用程序应该运行良好我已经在 cordova 2.7 和 3.0 下测试过

    3 - 如果您有一个全局错误处理程序,只需检查此错误是否已被触发并忽略它。

    【讨论】:

    • 这并不能真正回答问题。如果您有其他问题,可以点击 进行提问。一旦你有足够的reputation,你也可以add a bounty 来引起对这个问题的更多关注。
    • 我已经解决了这个问题并在这里发布了一个解决方案。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2018-12-04
    • 2021-12-22
    • 2016-04-17
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 2015-08-09
    • 1970-01-01
    相关资源
    最近更新 更多