1

I'm trying to get data using sharepoint web service, phoneGap and windows phone 8. When i test the code below it gives this error :

Error:"Unable to get property 'content' of undefined or null reference file:x-wmapp0:www/webs.html Line:1"

Any help please ?

<!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>
  • possible duplicate of http://stackoverflow.com/questions/14210765/unable-to-get-property-of-undefined-or-null-reference-windows-8-js-css-app – 4dgaurav Apr 11 '14 at 08:37

2 Answers2

0

This might be due to the version conflicts in the scripts you have included. Make sure that cordova-2.3.0.js can be used with jquery-1.4.4.js.

Madhu
  • 2,416
  • 3
  • 15
  • 33
-1

I know that this post is old However I wanted to help incase someone falls into it in the future.

1 - Make sure that deviceready event is available.

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

2 - Ignore the first error and the application should run well I have tested this under cordova 2.7 and 3.0

3 - If you have a global error handler just check if this error has been triggered and ignore it.