2014-03-19 16 views
0

我有以下代碼:CAML/SPServices/JQuery的錯誤

  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 .NET 4.0 .NET 4.0 ; InfoPath.3) 時間戳:Wed,19 Mar 2014 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的結果。

回答

1

我認爲這個問題是在這裏:

TYPE = 「查找」

用單引號代替雙引號。應該看起來像這樣:

Type ='Lookup'

+0

謝謝,知道這是愚蠢的! –

+0

不愚蠢。有時我們只需要一雙眼睛,特別是在看了太久之後。 :) –