【问题标题】:GetListItems Webservice ignores my query filterGetListItems Webservice 忽略我的查询过滤器
【发布时间】:2009-05-07 15:32:44
【问题描述】:

下面的代码看似执行 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>

【问题讨论】:

    标签: jquery web-services sharepoint


    【解决方案1】:

    我认为您需要将 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>"; 
    

    【讨论】:

      【解决方案2】:

      您缺少一个 。这些参数的格式有点违反直觉。

      我的博客上有一篇文章,其中包含一个工作示例:

      http://tqcblog.com/2007/09/24/sharepoint-blog-content-rating-with-javascript-and-web-services

      【讨论】:

      • 非常感谢 - 我一整天都在尝试各种选择!
      【解决方案3】:

      我也遇到了同样的问题..'Temple 的解决方案已经解决了查询问题..但是为了使 RowLimit 工作我将'R'设为小写,即,

      <rowLimit> not <RowLimit>
      

      这占用了我很多时间... :) 快乐编码...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-22
        • 2012-09-18
        • 1970-01-01
        • 2016-11-08
        相关资源
        最近更新 更多