I have the following code:
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
}
});
}
I get the following error when debugging in IE:
Webpage error details
User Agent: Mozilla/4.0 (compatible; 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) Timestamp: 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
Line 74 is:
async: false,
I do not get the error if I don't specify a value type, however the query returns 0 results.
I think the problem is here:
Type="Lookup"
Replace the double quotes with single quotes. Should look like this:
Type='Lookup'