0

I'm trying to use a CAML query to find a item from a SharePoint 2007 List based on the "cardID" value that is being retrieved through Javascript. I can see that the value is being assigned to the variable but whenever I try to add the query the list no longer displays. I'm hoping someone with more experience can clear up what I'm doing wrong.

Note: I used the u2u CAML tool to generate this query. When I execute it from there it returns a valid result just not when I try to use it in conjunction with jQuery.

 <script language = "javascript">  function GetAnnouncementData()  {  var soapPacket = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
    <soapenv:Body> \
     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
      <listName>eCards</listName> \ 
      <View> \ 
      <Query><Where>
      <Eq>
         <FieldRef Name='Title' />
         <Value Type='Text'>116</Value>
      </Eq></Where> </Query>
       <ViewFields> \   
      <FieldRef Name='Title' /> \ 
      <FieldRef Name='Greeting' /> \   
      <FieldRef Name='Message'/> \
      <FieldRef Name='Card' /> \
       </ViewFields> \ </View> \
     </GetListItems> \
    </soapenv:Body> \    </soapenv:Envelope>";  jQuery.ajax({    >url: "http://localhost/place/_vti_bin/lists.asmx",    type: "POST",    dataType: "xml",    data: soapPacket,    complete: processResult,    contentType: "text/xml; charset=\"utf-8\""   });  }  function processResult(xData, status) {   jQuery(xData.responseXML).find("z\\:row").each(function() {

JSRequest.EnsureSetup(); var cardID = JSRequest.QueryString["cardID"];

 $("<li>" + $(this).attr("ows_Title") + "</li>").appendTo("#AnnouncementData");  });  }

$(document).ready( function(){  GetAnnouncementData();  });   </script>

I've also tried replacing "cardID" with a predefined value that is in the list. Still no results are returned. :(

snapplex
  • 851
  • 3
  • 13
  • 27

1 Answers1

0

Please use the u2u CAML Builder tool to test your CAML query first: http://www.u2u.be/res/tools/camlquerybuilder.aspx

You could use Fiddler to see the traffic between the web service and the browser running the JavaScript. Debug JavaScript using Chrome (press F12). http://www.fiddler2.com/fiddler2/

Similar code here: http://community.office365.com/en-us/forums/153/p/13711/63998.aspx

sainiuc
  • 1,697
  • 11
  • 13
  • I probably should have mentioned that in my original post. I used the u2u CAML tool to generate this query. When I execute it from there it returns a valid result just not when I try to use it in conjunction with jQuery. – snapplex Oct 23 '12 at 17:40
  • Use Fiddler to see the request/response and debug your JavaScript. Give it another try! "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime". – sainiuc Oct 24 '12 at 09:41