$().SPServices.SPGetCurrentUser(); waitmessage

Aug 9, 2011 at 10:02 AM

Hi All,

I am using the waitmessage for SPServices library like this as given in some forums

 


var waitMessage = "<table width='100%' align='center'><tr><td align='center'><img src='/_layouts/images/gears_an.gif'/></td></tr></table>"; 

$("#dvpsm").html(waitMessage).SPServices({

But this is not working for the $("#dvpsm").html(waitMessage).SPServices.SPGetCurrentUser(); function.

if i give this it is still taking time to load ans not showing the image.

 

Since the SPGetCurrentUser() function is quite expensive is there a way to show the waiting image somehow?

 

Thanks in Advance

Coordinator
Aug 9, 2011 at 12:09 PM
Can you show all of your code? I assume that you have an element with its id="dvspm"?

M.
>
Aug 10, 2011 at 4:15 AM

Hi M,

Yes, your right dvspm is a blank div    

<div id="dvpsm">
    </div>

 

 

here is my complete code

 

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


  
$(document).ready(function() {
  
    var strHTML;
  
   query ="<Query><OrderBy><FieldRef Name='Hits' Ascending='False' /></OrderBy></Query>";


var waitMessage = "<table width='100%' align='center'><tr><td align='center'><img src='/_layouts/images/gears_an.gif'/></td></tr></table>"; 


strHTML="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><span class='sectionname'>Applications</span><br /><span class='featuretitle'>Most popular tools </span></td></tr><tr><td valign='top'><p><img src='http://eworkspace/teamsites/DS/groupworld/New%20Design%20groupworld/Key%20Section%20Templates/images/tools.jpg' width='477' height='100' hspace='0' vspace='0' /><u></u></p><table width='100%' border='0' align='right' cellpadding='0' cellspacing='0'>";


var currUser =$("#dvpsm").html(waitMessage).SPServices.SPGetCurrentUser();

 

$("#dvpsm").html(waitMessage).SPServices({
            webURL: "http://dxbegap19dv:2010/gw/tools/",
            operation: "GetListItems",
            listName: "tools",
            async: false,
            CAMLQuery: query,
           CAMLRowLimit:15 ,
            completefunc: function (OHHomeData, OHHomeStatus)
             {

         


 document.getElementById("dvpsm").innerText = OHHomeData.responseText;
var counter=0;
                $(OHHomeData.responseXML).find("[nodeName=z:row]").each(function(){        
            
               
              if(counter%3==0 && counter!=0)   
              {
          strHTML+="</tr>";                       
              }
        if(counter%3==0)
         {
          strHTML+="<tr>";                   
          }           
      
      
       strHTML+="<td width='37%' height='18' scope='col'><a onclick=\"recordhits('"+$(this).attr("ows_ID") +"','"+$(this).attr("ows_Hits") +"','"+$(this).attr("ows_url") +"');\" href='#'>"+$(this).attr("ows_LinkTitle")+"</a></td>";
    counter++;
            });
       
          strHTML+="</tr></table></td></tr><tr><td align='left'><a href='moreapps.aspx'>View All</a></td></tr></table>" ;
         
 document.getElementById("dvpsm").innerHTML=strHTML;
          }
        });
        });

function recordhits(valId,CurrentHit,url)
{
 


var newID=eval(CurrentHit)+1;

$().SPServices({
webURL:"http://dxbegap19dv:2010/gw/tools/",
 operation: "UpdateListItems", async: false, batchCmd: "Update", listName: "tools", valuepairs: [["Hits",newID]],ID:valId, completefunc: function(xData, Status) {

OpenCSApps(valId,url)

//alert(Status);

}
});
}


function OpenCSApps(objID,url){
 if(screen.width > 800){
  var Property = "height="+(545)+ "," +"width=800" + ",top=50,left=112,menubar=0";
 }else{
  var Property = "height="+(550)+ "," +"width=795" + ",top=0,left=0,menubar=0";
 } 

 switch (objID){
  case "1":
   window.open('/mds/login.htm','WF',Property); 
   break;
  case "2":
   window.open('mds/Em_post/Administration/AdminHome.aspx','CSAdmin',Property); 
   break;
   
  default: window.location.href = url;
  
  }

 }

</script>

 

 

<div id="dvpsm">
</div>

Thanks a lot

Janesh

Coordinator
Aug 10, 2011 at 12:09 PM
Edited Aug 16, 2011 at 4:14 AM

Janesh:

I'll have to do some testing with this. It looks like you're doing things correctly. Do you see the "gears" with the GetListItems call?

Note that as of jQuery 1.5, you MUST enclose z:row in single quotes:

.find("[nodeName='z:row']")

M.