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

async: true?

Aug 4, 2011 at 2:33 PM

I've noticed that most of my code I have to include:

async: false

I'm sure there is a good reason the default is set to true, but I can't figure it out.  What's the reasoning behind this option's default being true?

Aug 4, 2011 at 2:38 PM


When I first started looking at building SPServices, I saw that the default setting for async in .ajax in jQuery was true. It seemed to make more sense to stick with jQuery's default than to reverse it.

You're right that in the majority of cases with SPServices we end up setting async to false.


Aug 4, 2011 at 3:34 PM

I was asking b/c I keep running into weird errors and the last 5-6 of them it's been tracked down to this setting.  What would be the pros/cons of switching that, if at all possible?  I know I can mod my own library, but what's good for me, may be good for the crowd.

Aug 4, 2011 at 3:37 PM

I'm going to leave it as-is. Switching it now would cause all sorts of headaches.

I assume that the werid errors are caused by your own code?


Aug 4, 2011 at 4:32 PM

var processingList = false;

$().SPServices({ do fun stuff });

if ( processingList ) {

//run some code...


processingList is a boolean set during the SPServices call, but if it's set to async: true (by default), then my if statement never runs b/c of a falsey value...  It's one of those HEH?!? moments, when you are debugging and a simple boolean that should be true isn't firing b/c of a timing issue.  Oh well... :/

Aug 10, 2011 at 5:10 AM

With async=true your page loads faster, as it doesn't wait for the AJAX call to complete. This is the standard way to proceed. To process the data returned from the AJAX call, you associate a function to the onSuccess property.

Aug 10, 2011 at 2:41 PM

The ability to bind functions to the onSuccess, onError, or statusCode methods within jQuery would be fantastic to have within SPServices.  Would that be something you would consider adding in SPServices Marc?

Aug 10, 2011 at 5:19 PM

This is already available. In SPServices, the property is called completefunc.

Aug 10, 2011 at 6:31 PM
Edited Aug 10, 2011 at 6:35 PM

SPServices will *not* allow you to call upon the methods described on this page:

The ajax call is hardcoded and only provides a completefunc, but I cannot call statusCode or call upon any other properties contained within it.  These seem like they could provide value in some instances.

Aug 10, 2011 at 6:44 PM

Well, how about using this, for example for your statusCode:

Aug 10, 2011 at 9:17 PM

Now, that is awesomesauce!  Thanks much Christophe!!!