spserviceprob

Jul 14, 2011 at 10:41 PM

I found a discussion where someone was having a problem with using a basic SPServices function, but found that it was resolved.  So, I am starting another discussion.  I am new to Sharepoint and jQuery/SPServices so please be patient with me!!

I believe I am having a reference problem with SPServices.  Let's say the URL for my website is http://.../default.aspx and I place the jQuery and SPServices libraries in a Doc Library located in http://.../Scripts/Forms/AllItems.aspx.  I tried using src="/Scripts/Forms/jquery-1.6.2.min.js" and src="/Scripts/Forms/jquery.SPServices-0.6.2.min.js", but I could not get either of them to work.  So I used the jQuery library hosted by Google (see code below) and I got it to work with a script other than the one below.  I have not found a site that hosts SPServices-0.6.2 (the one in the code below does not work), so I can't get that to work period! 

Nothing happens when I save the changes to the CEWP, except that I get a "Please wait while scripts are loaded…" error.  The alerts don't return anything and, of course, the "GetListItems" isn't working either.  The only thing that's working is the HTML to show the Search button.  Thank you very much to anyone that can help me!!  Following is code I entered into a Content Editor Web Part (CEWP):

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

<script type="text/javascript" src="http://sharepoint/scriptcenter/jquery/jquery.SPServices-0.6.2.min.js"></script>

<script type="text/javascript">

 function RedirectUrl()
 {

 var tb = document.getElementById("tbSearch").value;
 var cs = document.getElementById("sfield").value;
        var query = "<Query><Where><Eq><FieldRef Name=" + cs + "/><Value Type='Text'>" + tb + "</Value></Eq></Where></Query>";

     alert("jQuery"); 

     alert($().SPServices.SPGetCurrentSite()); 

 $().SPServices({
  operation: "GetListItems",
             listName: "{E73FEA09-CF8F-4B30-88C7-6FA996EE1706}",
             async: false,
             CAMLQuery: query,
             completefunc: function (xData, Status) {
                 $(xData.responseXML).find("[nodeName=z:row]").each(function(){
               var liHtml = "<li>" + $(this).attr("ows_Youth_x0020_ID") + ": " + $(this).attr("ows_First_x0020_Name") + ": " + $(this).attr("ows_Last_x0020_Name")" + "</li>";
               $("#tasksUL").append(liHtml);
                 });
             }
 });
 }
 

</script>

<ul id="tasksUL"/>


<!-- ////////////////////////////////////////////////////////////////////////////////////////////// -->
Search Field: <select id="sfield">
<option selected value="LinkTitle" >Title</option>
<option value="Youth_x0020_ID">Youth ID</option>
<option value="First_x0020_Name">First Name</option>
<option value="Last_x0020_Name">Last Name</option>
<option value="Date_x0020_Of_x0020_Birth">Date of Birth</option>
<option value="Enrollment_x0020_Date">Enrollment Date</option>
</select>
&nbsp;
Search text: <input type="text" id="tbSearch" />
<input type="button" id="btnSearch" value="Search" onclick="return RedirectUrl();" />