Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

enter code hereI am using an example I found on codeplex of SPServices with CamlQuery to try to get list item values with where clause on the ID. For whatever reason this doesn't seem to work for me; please help!

function getToolInfo(lastID) {

    var CamlQuery = "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>" + lastID + "</Value></Eq></Where></Query>";
    var CamlViewFields = "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /></ViewFields>";

  // this let me know that the function is getting called and passed the correct parameter value
  alert('function called and passed last ID of : ' + lastID);
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "FirstList",
    CAMLViewFields: CamlViewFields,
    CAMLQuery: CamlQuery,
      completefunc: function (xData, Status) {
        $(xData.responseXML).find("[nodeName='z:row']").each(function() {

        // just load a new variable with the returned value        
        var thisID = $(this).attr("ows_ID");
        alert(thisID);

      });
    }
  });
}

did I miss something obvious here? basically all the alerts are working except for the last.

Additionally if I remove this line:

$(xData.responseXML).find("[nodeName='z:row']").each(function() {

then i can add alert that works. I have double, triple, etc checked the list item with that ID and it is there.

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

If you are using jQuery 1.7+, the syntax you are using to find the z:row elements no longer works. Use the SPFilterNode function instead.

share|improve this answer
    
Well, it's in the documentation....in big bold red caption at that. Appreciate it Marc, I missed that. :) –  Justin Jun 22 '12 at 10:40
1  
Maybe I should switch to marquee and flashing. :-) –  Marc D Anderson Jun 22 '12 at 14:39
add comment
$(xData.responseXML).find("z\\:row").each(function () {

Change your line as I mentioned above. I have tested and it's working also in later versions of jQuery

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.