【问题标题】:CAML / SPServices / JQuery ErrorCAML / SPServices / JQuery 错误
【发布时间】:2014-03-19 15:29:40
【问题描述】:

我有以下代码:

            function ViewItems() {

    var liHtml = ''; //Set the variable to nothing
    alert($('#categoryselect').val());
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Items",
        CAMLQuery: "<Where><Eq><FieldRef Name='Category'/><Value Type="Lookup">" + $('#categoryselect').val() + "</Value></Eq></Where>",
        CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Image' /></ViewFields>",
        completefunc: function (xData, Status) {

        $(xData.responseXML).SPFilterNode("z:row").each(function() {

            liHtml = liHtml + "<h1>" + $(this).attr("ows_Title") + "</h2><br /> <img width=\"150px\" src=\"" + ($(this).attr("ows_Image")).split(", ")[0] + "\"  /><br /> <a id=" + $(this).attr("ows_ID") + " class=\"addtobasket\">[Add To Basket]</a>";
        });


     $("#tasksUL").html(liHtml); //Fill the div with the liHTML


    }
    });
    }

在 IE 中调试时出现以下错误:

网页错误详情

用户代理:Mozilla/4.0(兼容;MSIE 8.0;Windows NT 6.1;Trident/4.0;SLCC2;.NET CLR 2.0.50727;.NET CLR 3.5.30729;.NET CLR 3.0.30729;Media Center PC 6.0 ; .NET4.0C; .NET4.0E; InfoPath.3) 时间戳:2014 年 3 月 19 日星期三 15:27:28 UTC

Message: Expected '}'
Line: 74
Char: 77
Code: 0
URI: MY SP Site


Message: Could not complete the operation due to error 80020101.
Line: 2
Char: 2568
Code: 0
URI: /Assets/jquery.js

第 74 行是:

async: false,

如果我没有指定值类型,我不会收到错误,但是查询返回 0 个结果。

【问题讨论】:

    标签: jquery caml spservices


    【解决方案1】:

    我认为问题出在这里:

    Type="查找"

    用单引号代替双引号。应该是这样的:

    Type='查找'

    【讨论】:

    • 不傻。有时我们只需要第二双眼睛,特别是在看东西太久之后。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多