New to SPServices, GetListItems is not displaying anything

Jan 6, 2011 at 3:01 PM

Hi, I am new to SpServices and i tried using the function GetListItems, but nothing was displayed on my window. I have created custom list (OnCallList) and i would like to read the list and get the items from the list. Please find the code below.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/testRenova/Documents/jquery.SPServices-0.5.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
alert("alert test");
$().SPServices({
$().SPServices({
  operation: "GetListItems",
  async: false,  
  listName: "OnCallList",
  CAMLQuery: "<Query><Where><Eq><FieldRef Name="OnCall" /><Value Type="Boolean">yes</Value></Eq></Where></Query>",
  completefunc: function (xData, Status) {
alert(xData.responseXML.xml);
$("#output").append("test");
    $(xData.responseXML).find("[nodeName=z:row]").each(function() {      alert("This alert is NOT firing!");      $("#output").append($(this).attr("ows_Title") + "<br />");
    });
  }
});
});
</script>

Please help me to get the value.

Thanks,

Coordinator
Jan 6, 2011 at 3:12 PM

neelima:

You've got SPServices twice in your code. You're also using double quotes inside double quotes, which won't fly.  Try this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/testRenova/Documents/jquery.SPServices-0.5.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
alert("alert test");
$().SPServices({
  operation: "GetListItems",
  async: false,  
  listName: "OnCallList",
  CAMLQuery: "<Query><Where><Eq><FieldRef Name='OnCall' /><Value Type='Boolean'>yes</Value></Eq></Where></Query>",
  completefunc: function (xData, Status) {
alert(xData.responseXML.xml);
$("#output").append("test");
    $(xData.responseXML).find("[nodeName=z:row]").each(function() {
      alert("This alert is NOT firing!");
      $("#output").append($(this).attr("ows_Title") + "<br />");
    });
  }
});
</script>

M.

Jan 6, 2011 at 3:32 PM

Hi,

Thank you so much for the reply. I just copied and pasted your code, but still i do not see anything on the page. Am i missing anything..?

Thanks,

 

 

Coordinator
Jan 6, 2011 at 10:43 PM
Do you get both alerts? You might want to remove the CAMLQuery to see if you are getting results from the Web Service call. M.
Jan 7, 2011 at 1:23 PM

I don't get any alert at all, not even the first one. As you said, I have removed CAML query also, but still there is no luck. I have only one item in the list and script files for the spservices are in sharepoint document library. It seems everything is fine, donno why it's not working. Any other suggestions for me....?

Coordinator
Jan 7, 2011 at 1:27 PM
If you're not getting any alerts at all, then your src links are probably wrong. In SharePoint Designer, you can Ctrl-Click to see if the files open up. Check the links and you'll probably be up and running. M.
Jan 7, 2011 at 6:41 PM

Thank you so much for the quick reply. When i tried clicking on the SpServices src link I was getting the eror but when i went into doc library and open the file with notepad, everything was fine. Should I do something to have that js file available to the sharepoint site.?

Also, i would like to tell you about my requirement, so that i hope you can help me with proper library to use from codeplex. My requirement is...

1.Get employees data from SQL server.

2. Maintain OnCall list in sharepoint custom list

3. Compare the SQL server employee data with sharepoint custom list and highlight/show some image on the employee row who is OnCall for that week.

My Idea of implementing was, using SPServices I should get sharepoint list data and compare SQL data using JQuery. i don't know whether it's a feasible solution now as I cannot even read the list through SPServices.

I am really sorry if I asked too much from you.

Thank you so much.

 

Coordinator
Jan 7, 2011 at 6:45 PM

It sounds like
src="http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/testRenova/Documents/jquery.SPServices-0.5.6.min.js"
isn't a valid path. Even if you can go to the Document Library and open the file, the src attribute must point to the file so that it is accessible at run time.

M.

Jan 9, 2011 at 4:41 AM

Hi Mark,

At last I found out the reason why my code was not working. I just changed the src attribute to the value

/Admin/IT/Application Development Group/testRenova/Documents/jquery.SPServices-0.5.8.min.js" type="text/javascript"

and it worked fine. I just took out % symbols.

Thank you so much for all your suggestions.

 

Coordinator
Jan 9, 2011 at 2:29 PM
Looks like you were referencing the wrong filename, actually. ;-). The %20 notation is just an encoded space (a space is the ASCII character 20) and doesn't cause any problem. In any case, I'm glad you got things up and running! M.
Jan 10, 2011 at 2:04 PM

Hi Mark,

I need a small clarification... I am trying to use parent().css in Spservices code, but It's not working for me. I sthere any limitation for not using this in Spservices()?

Thanks once again...

 

Coordinator
Jan 10, 2011 at 3:19 PM
There's nothing in SPServices that prevents you from using any part of jQuery, so my guess is that your selector is just off. M.