我正在向sharepoint服务发送一个jquery / ajax post请求,并希望获得xml,以便我可以使用它来创建调查。这是我第一次使用jQuery,所以我对它很陌生。任何帮助表示赞赏。 顺便说一句,我得到一个"装载"警告所以我知道jquery正在加载。
<script type="text/javascript">
$(document).ready(function () {
alert('loaded');
var xmlData = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><soap:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>Shared Documents</listName><query><Query xmlns=''><OrderBy><FieldRef Name='Title' /></OrderBy></Query></query><viewFields><ViewFields xmlns='' /></viewFields><queryOptions><QueryOptions xmlns='' /></queryOptions></GetListItems></soap:Body></soap:Envelope>";
$.ajax({
type: "POST",
url: "http://mkspintrat01/_vti_bin/Lists.asmx",
dataType: "xml",
data: xmlData,
complete: SuccessFunc,
error: ErrorFunc,
contentType: "text/xml; charset=\"utf-8\""
});
});
function SuccessFunc(result) {
// xml node with namespace need to be handled differently for jQuery
$(result.responseXML).find("z\\:row").each(function () {
alert($(this).attr("ows_Title"));
});
} function ErrorFunc(result) {
alert("failed");
//alert(result.responseText);
}
</script>