gpt4 book ai didi

jquery - GetListItems Web 服务忽略我的查询过滤器

转载 作者:行者123 更新时间:2023-12-01 00:47:16 24 4
gpt4 key购买 nike

下面的代码看似执行 Web 服务并返回值,但忽略了 where 子句(从而返回列表中的所有项目)。这是我提出的问题的最简单形式。

TestQuery 列表是一个简单的自定义列表,没有用户定义的字段。谁能明白为什么过滤器不起作用?

<body>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<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/'>";
soapEnv += "<listName>TestQuery</listName>";
soapEnv += "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>One</Value></Eq></Where></Query>";
soapEnv += "<ViewFields><ViewFields><FieldRef Name='Title'/></ViewFields></ViewFields><RowLimit>1</RowLimit>";
soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

$.ajax({
url: "_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});

function processResult(xData, status) {
$('#WSResponse').text(status);
$(xData.responseXML).find("z\\:row").each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
//}
}
</script>


<ul id="tasksUL"/>
<div id="WSResponse"/>

</body>

最佳答案

我认为您需要将 Query 标签放在查询标签内,将 ViewField 放在 viewField 标签内,如下所示:

var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"; 
soapEnv += "<listName>TestQuery</listName>";
soapEnv += "<query><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>One</Value></Eq></Where></Query></query>";
soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/></ViewFields></viewFields><RowLimit>1</RowLimit>";
soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

关于jquery - GetListItems Web 服务忽略我的查询过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/835358/

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