gpt4 book ai didi

javascript - AJAX responseXML 为空,带有 jQ​​uery UI 模态表单

转载 作者:行者123 更新时间:2023-11-28 08:59:55 26 4
gpt4 key购买 nike

我有一个对 SharePoint Web 服务的 jQuery ajax 调用,我用它来将“搜索”结果附加到表中。仅使用一个简单的 html 表,一切工作正常,并且添加了结果,但是当我尝试将结果添加到 jQuery UI 模式表单时,调用返回 0 个结果,responseXML 似乎为 null(responseText 返回预期的字符串)。我希望我只是错过了一些简单的事情。欢迎任何想法。

HTML:

<p id="myDescrip">This is a test page for CAML Web Service Queries</p>
<button id="SearchItems">Search for Transcripts</button>
<div id="dialog-results" title="Search Results">
<p id="myResults">Your search results are:</p>
<table id="SearchData" class="myTable">
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Transcripts School</th>
<th>Date Received</th>
</tr>
</table>
</div>

JavaScript(jQuery/jQuery UI):

$(function() {
// Button control
$( "#SearchItems" )
.button()
.click(function() {
SearchTranscripts();
});
// Dialog control
$( "#dialog-results" ).dialog({
autoOpen: false,
resizable: false,
height:300,
width:500,
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
// Query the SharePoint list
function SearchTranscripts() {
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>"
soapEnv += "<soapenv:Body>"
soapEnv += "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"
soapEnv += "<listName>Transcripts Log</listName>"
soapEnv += "<query><Query><Where><Or><Contains><FieldRef Name='Title' /><Value Type='Text'>Smith</Value></Contains>"
soapEnv += "<Contains><FieldRef Name='First_Name' /><Value Type='Text'>Smith</Value></Contains></Or></Where>"
soapEnv += "<OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query></query>"
soapEnv += "<viewFields>"
soapEnv += "</viewFields>"
soapEnv += "<rowLimit>5000</rowLimit>"
soapEnv += "</GetListItems>"
soapEnv += "</soapenv:Body>"
soapEnv += "</soapenv:Envelope>";

$.ajax({
url: "/xxx/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
error: errorResult,
contentType: "text/xml; charset=\"utf-8\""
});
}
// Add items to the list
function processResult(xData) {
var myFname = "";
var myLname = "";
var mySchool = "";
var myDate = "";
var myID = "";
var itemUrl = "/xxx/DispForm.aspx?ID=";
var nr = 0;

$(xData.responseXML).find("z\\:row").each(function () {
myFname = $(this).attr("ows_First_Name");
myLname = $(this).attr("ows_Title");
mySchool = $(this).attr("ows_College");
var tmpd = $(this).attr("ows_Date_Received");
// Check for invalid dates
if(!tmpd){
myDate = "n/a";
} else {
myDate = tmpd.substring(5, 7).replace("0","") + "/"
myDate += tmpd.substring(8, 10).replace("0","") + "/"
myDate += tmpd.substring(0, 4);
}
myID = $(this).attr("ows_ID");
// Create the new row
var AddRow = "<tr><td><a href='" + itemUrl + myID + "'>" + myLname + "</a></td>"
AddRow += "<td>" + myFname + "</td>"
AddRow += "<td>" + mySchool + "</td>"
AddRow += "<td>" + myDate + "</td></tr>"
$("#SearchData").append(AddRow);
nr += 1;

});
$("#myResults").html($("#myResults").html() + " " + nr)
$( "#dialog-results" ).dialog( "open" );
}
// Show Error
function errorResult(xData) {
alert(xData.responseText);
}

最佳答案

该问题是 jQuery 1.9.1 的 responseXML 错误。正如我在评论中提到的,使用 1.8.3 版本“解决”了这个问题。您可以在 jQuery bug tracker 上阅读更多信息。以及 this blog .

关于javascript - AJAX responseXML 为空,带有 jQ​​uery UI 模态表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17890640/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com