This project has moved and is read-only. For the latest updates, please go here.

Request takes over a second

Feb 11, 2015 at 9:47 PM
We are using 2104.01 SpServices in 5 webparts on one page to query 5 different lists. When I trace the network activity, the request from the browser takes somewhere between 1-1.5 seconds waiting on a response. This causes the page to take up to 8 seconds to load. Any thoughts?

This is one of the queries:
var method = "GetListItems";
var list = "LIST";

var fieldsToRead = "<ViewFields>" +
                        "<FieldRef Name='Title' />" +
                        "<FieldRef Name='Icon' />" +
                         "<FieldRef Name='Link' />" +
                         "<FieldRef Name='HoverIcon' />" +

var query = "<Query>" +
                "<Where>" +
                    "<And>" +
                        "<Neq>" +
                            "<FieldRef Name='ID'/><Value Type='Number'>0</Value>" +
                        "</Neq>" +
                         "<Eq>" +
                            "<FieldRef Name='Status'/><Value Type='Text'>Active</Value>" +
                        "</Eq>" +
                    "</And>" +
                "</Where>" +
                "<OrderBy>" +
                    "<FieldRef Name='SortOrder'/>" +
                "</OrderBy>" +

//Here is our SPServices Call where we pass in the variables that we set above
    operation: method,
    async: false,  //if you set this to true, you may get faster performance, but your order may not be accurate.
    listName: list,
    CAMLViewFields: fieldsToRead,
    CAMLQuery: query,
    //this basically means "do the following code when the call is complete"
    completefunc: function (xData, Status) {
        //this code iterates through every row of data returned from the web service call
        $(xData.responseXML).SPFilterNode("z:row").each(function () {
            var name = ($(this).attr("ows_Title"));
            var Url = ($(this).attr("ows_Link")).split(",")[0];
            var Icon = ($(this).attr("ows_Icon")).split(",")[0];
            var HoverIcon = ($(this).attr("ows_HoverIcon")).split(",")[0];

            //call a function to add the data from the row to a div
            AddDivStandardQuickLinks(name, Url, Icon, HoverIcon);
Feb 11, 2015 at 9:57 PM
You should switch to use promises. SPServices returns a promise from every call to the core operations. That will keep the page from hanging up, as right now you're doing the calls synchronously.

You should also upgrade to 2014.02, as there are some other efficiencies.