我尝试使用sharepoint网络服务,phoneGap和Windows Phone 8获取数据。 当我测试下面的代码时,它会给出这个错误:
错误:"无法获取属性'内容'未定义或空引用文件:x-wmapp0:www / webs.html行: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>
答案 0 :(得分:0)
这可能是由于您包含的脚本中的版本冲突所致。确保cordova-2.3.0.js
与jquery-1.4.4.js
一起使用。
答案 1 :(得分:-1)
我知道这篇文章很老了但是我想帮助将来有人陷入其中。
1 - 确保deviceready事件可用。
document.addEventListener("deviceready", function () { });
2 - 忽略第一个错误并且应用程序应该运行良好我已经在cordova 2.7和3.0下进行了测试
3 - 如果您有一个全局错误处理程序,只需检查是否已触发此错误并忽略它。