SPServices 2013.01 - Test

May 10, 2013 at 4:46 PM
I am newbie to both JQuery and SPServices. I recently testing v.72 and works fine on my SP2010 environment. Yesterday, I downloaded the 2013.01 release and replace my library reference in my existing code to use this new release. However, the page does not render anything and I don't see any errors in Firebug.

So, am I missing something? Thanks
Coordinator
May 10, 2013 at 5:02 PM
You ought to be able to replace 0.7.2 with 2013.01 and see identical results. I've tried very hard to maintain backward compatibility.

Have you checked the Net tab in Firebug to make sure that the script is loading correctly?

M.
May 10, 2013 at 5:09 PM
Hi Marc,

Thanks for the quick response. Yes, I do see an entry in the Net tab:

"__Http://vti_bin/Lists.asmx Aborted vti_bin 0b"


If I restore the .72 reference, it works fine.
Coordinator
May 10, 2013 at 5:18 PM
Can you post your code?

M.
May 10, 2013 at 5:22 PM

<script language="javascript" type="text/javascript">

$(document).ready(function() {  //-----------SPSERVICES GET ALL LIST ITEMS FROM THE LIST
  var htmlTable = '<table>';
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Thisweek",
    CAMLRowLimit: 10,
    CAMLViewFields: "<ViewFields>" +
                        "<FieldRef Name='Title'></FieldRef>" +
                        "<FieldRef Name='Created'></FieldRef>" +
                    "</ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {  //--------FIND EACH RECORD FROM THE LIST
        var id = $(this).attr("ows_ID");
        htmlTable += "<tr>" +
                        "<td>" + 
                        "<a href=\"javascript:\" + onclick=\"OpenModalDialog('" + id + "')\">" + 
                        "<img src='/_layouts/images/StopHS.png' width='11' height='11'/>" + "&nbsp" +
                        $(this).attr("ows_Title").substr(0,50) +
                        "</a>" +
                        SPConvertDate($(this).attr("ows_Created")) + 
                        "... " + 
                        "</td>" +
                    "</tr>";
        })      
        htmlTable += "</table>";
        $("#htmlTableOutput").html(htmlTable);
    }
  });
});

//---------------------------------------------
//-------- THIS IS THE MODEL DIALOGUE FUNCTION
//---------------------------------------------
function OpenModalDialog(id) {
    var options = {
        url: "/Lists/Thisweek/DispForm.aspx?ID=" + id,
        title: "This Week ",
        width: 800,
        height: 1000,
        dialogReturnValueCallback: DialogAnnouncementCallback
    };
    SP.UI.ModalDialog.showModalDialog(options);
}

function DialogAnnouncementCallback(dialogResult, returnValue) { }

//---------------------------------------------
//-------- CONVERTS DATE TO MM/DD/YYYY FORMAT
//---------------------------------------------
function SPConvertDate(t){
     var d = new Date(t.substr(0,4), parseInt(t.substr(5,2)) - 1, t.substr(8,2), t.substr(11,2), t.substr(14,2), t.substr(17,2));
     var month = ((d.getMonth()+1) < 10) ? "0" + (d.getMonth()+1) : (d.getMonth()+1);
     var date = (d.getDate() < 10) ? "0" + d.getDate() : d.getDate();
     var minutes = (d.getMinutes() < 10) ? "0" + d.getMinutes() : d.getMinutes();
     var amPm = (d.getHours() < 12) ? "am" : "pm";
     return " [" + month + "/" + date + "/" + d.getFullYear() + "]";
}

</script>


<div id="htmlTableOutput"></div>



Coordinator
May 10, 2013 at 6:31 PM
I don't see anything obvious. You aren't using jQuery 1.9.x, are you? Those versions have bugs that prevent them from working with SPServices.

M.
May 10, 2013 at 9:40 PM
Edited May 10, 2013 at 9:46 PM
Here are the references:
<script language="javascript" src="/_layouts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
<script language="javascript" src="/_layouts/jquery/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>
<script language="javascript" src="/_layouts/jquery/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script language="javascript" src="/SiteAssets/jquery/jquery.balloon.min.js" type="text/javascript"/></script>
<link rel="stylesheet" href="/_layouts/jquery/jquery-ui-themes-1.10.0/themes/smoothness/jquery-ui.css" type="text/css"/>
May 13, 2013 at 7:32 PM
Thinking it could be the other references that may cause the issue, I decided to try only these two. Same result.... : (
<script language="javascript" src="/_layouts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
<script language="javascript" src="/_layouts/jquery/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>
Coordinator
May 13, 2013 at 7:48 PM
I still can't see anything that would throw an error. Check in the IE Developer Toolbar in the console to see if there are errors. Usually Firefox won't even load the script file if there is an error.

M.
May 13, 2013 at 8:30 PM
Thanks Marc. Looking at the page load in IE Dev Toolbar, I do see a reference to JQuery-1.7.1.min.js somewhere. I believe this came from a custom Masterpage that a vendor had done for us. Could their be a conflict somewhere between this and the new 2013 library?

So, without messing with the custom masterpage, is there a way to change my script above to ignore/bypass the conflict(s)?

Thanks
May 13, 2013 at 10:38 PM
Okay. Did some more testings. I use the below code (in CEWP) on a clean SP2010 machine. The result is the same... blank screen. If I change SPServices bck to .7.2, it works. You can try it with the below code but change the userLoginName.
<script language="javascript" src="/_layouts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
<script language="javascript" src="/_layouts/jquery/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
    waitMessage = "<table width='100%' align='center'><tr><td align='center'><img src='/_layouts/images/gears_an.gif'/></td></tr></table>";
    $("#WSOutput").html(waitMessage).SPServices({
        operation: "GetUserInfo",
        userLoginName: "__MYDOMAIN\USERNAME__",
        completefunc: function (xData, Status) {
            $("#WSOutput").html("").append("<b>This is the output from the GetUserInfo operation:</b>");
            $(xData.responseXML).find("User").each(function() {
                $("#WSOutput").append("<li>ID: " + $(this).attr("ID") + "</li>");
                $("#WSOutput").append("<li>Sid: " + $(this).attr("Sid") + "</li>");
                $("#WSOutput").append("<li>Name: " + $(this).attr("Name") + "</li>");
                $("#WSOutput").append("<li>LoginName: " + $(this).attr("LoginName") + "</li>");
                $("#WSOutput").append("<li>Email: " + $(this).attr("Email") + "</li>");
                $("#WSOutput").append("<li>Notes: " + $(this).attr("Notes") + "</li>");
                $("#WSOutput").append("<li>IsSiteAdmin: " + $(this).attr("IsSiteAdmin") + "</li>");
                $("#WSOutput").append("<li>IsDomainGroup: " + $(this).attr("IsDomainGroup") + "</li>");
                $("#WSOutput").append("<hr/>");
            });
        }
    });
</script>

<ul id="WSOutput"/>
Coordinator
May 14, 2013 at 5:01 AM
Edited May 14, 2013 at 5:03 AM
Hmm. This works for me in my Office365 tenant that's still running SharePoint 2010. It's basically the same as your code with different references to the libraries and my account info.

I did notice that when I forgot to set the account correctly that I got "blank" results because the call gave an error. i.e., I only saw the "This is the output from the GetUserInfo operation:" text.

M.
<!-- Reference jQuery on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Reference SPServices on cdnjs (Cloudflare) -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2013.01/jquery.SPServices-2013.01.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {
    waitMessage = "<table width='100%' align='center'><tr><td align='center'><img src='/_layouts/images/gears_an.gif'/></td></tr></table>";
    $("#WSOutput").html(waitMessage).SPServices({
        operation: "GetUserInfo",
        userLoginName: "i:0#.f|membership|marc@mydomain.com",
        completefunc: function (xData, Status) {
            $("#WSOutput").html("").append("<b>This is the output from the GetUserInfo operation:</b>");
            $(xData.responseXML).find("User").each(function() {
                $("#WSOutput").append("<li>ID: " + $(this).attr("ID") + "</li>");
                $("#WSOutput").append("<li>Sid: " + $(this).attr("Sid") + "</li>");
                $("#WSOutput").append("<li>Name: " + $(this).attr("Name") + "</li>");
                $("#WSOutput").append("<li>LoginName: " + $(this).attr("LoginName") + "</li>");
                $("#WSOutput").append("<li>Email: " + $(this).attr("Email") + "</li>");
                $("#WSOutput").append("<li>Notes: " + $(this).attr("Notes") + "</li>");
                $("#WSOutput").append("<li>IsSiteAdmin: " + $(this).attr("IsSiteAdmin") + "</li>");
                $("#WSOutput").append("<li>IsDomainGroup: " + $(this).attr("IsDomainGroup") + "</li>");
                $("#WSOutput").append("<hr/>");
            });
        }
    });

});


</script>

<ul id="WSOutput"/>
May 14, 2013 at 5:48 PM
Edited May 14, 2013 at 5:54 PM
Strange. When I try your code (using my login ID), it only display "This is the output from the GetUserInfo operation:". If I change the reference back to 0.7.2.min.js, it works fine.
Coordinator
May 14, 2013 at 6:52 PM
Hmm. When you look at the request in the Net tab in Firebug, what does the response packet look like? Or don't you even get one?

M.
May 14, 2013 at 7:45 PM
I see one error:

"http://_vti_bin/usergroup.asmx Aborted _vti_bin 0B"


I see this on my PROD farm and on my standalone vanilla dev server.
Coordinator
May 14, 2013 at 8:20 PM
OK, that's not a valid URL, obviously. How do you have the URL set up in 2010?

M.
May 14, 2013 at 8:39 PM
For the dev server, I am using just the server name and nothing else as this is AIO server. There's no AAM involved. For my PROD farm, the web app uses a host header to connect... nothing fancy. So, why would the previous version of SPServices works?
May 15, 2013 at 12:20 AM
Okay. This time, I added the webURL to the mix and ran it again. The Firebug error went away. However, the page is still blank.
webURL: "http://THESITEURL",
Coordinator
May 21, 2013 at 4:56 AM
Did you get this working?

M.
May 21, 2013 at 4:54 PM
Hi Marc,

Thanks for the follow-up. Unfortunately, still the same result. I have tried this on 3 different farms (Prod, dev, some other) with the same result. It works fine if I switch back to 7.2.

For now, I am going to use 7.2 and see if someone else have the same issue.
May 21, 2013 at 5:08 PM
One additional note, when I look at the "POST usergroup.asmx" Response (Net tab) in IE's Dev Tool, it shows the following:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetUserInfoResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"><GetUserInfoResult><GetUserInfo><User ID="16" Sid="S-1-5-21-1383155457-1796633636-1831341646-22317" Name="MY NAME" LoginName="MYDOMAIN\My.NAME" Email="MY.NAME@DOMAIN" Notes="" IsSiteAdmin="False" IsDomainGroup="False" Flags="0" /></GetUserInfo></GetUserInfoResult></GetUserInfoResponse></soap:Body></soap:Envelope>
Based on the the above, it appears that the data was successfully retrieved thru the SPSerivces. But why is it not displaying it?
Coordinator
May 21, 2013 at 5:18 PM
I think you'll need to step through youtr script to see what's happening. Since it worked for me and you can see that results are coming back, it's got to be something in your page.

M.
May 21, 2013 at 8:36 PM
Thanks Marc. I will. Just bugs that the same code works with the old library but not the latest one.