[cosmo-dev] Putting the A back in Ajax

Travis Vachon travis at osafoundation.org
Wed Nov 14 09:42:19 PST 2007


Hi folks

The recent problem on hub highlighted a flaw in our client code,  
namely our use of synchronous XHR calls. A grep for the parameter that  
makes this happen looks like:

~/Development/osaf/cosmo/git/cosmo/src/main/webapp/js/cosmo% grep -r - 
e "sync: \?true" *
app/pim.js:               var collection =  
this.serv.getCollection(params.collectionUrl, {sync:true}).results[0];
app/pim.js:            var userCollections =  
this.serv.getCollections({sync: true}).results[0];
app/pim.js:            var subscriptions =  
this.serv.getSubscriptions({sync:true}).results[0];
service/conduits/ 
common 
.js:                                                               
{sync: true}).results[0];
service/conduits/ 
common 
.js:                                                               
{sync: true, noAuth: true}).results[0];
ui/imagegrid.js:    sync: true,
view/cal/common.js:                        { start: start, end: end },  
{ sync: true });
view/list/canvas.js:                { sync: true })];
view/list/canvas.js:                  { sync: true }));
view/list/common.js:            { sync: true });
view/service.js:                var deferred =  
cosmo 
.app 
.pim 
.serv.getCollection(cosmo.app.pim.currentCollection.getUrls().self,  
{sync:true});


As you can see, we're using synchronous calls quite a bit.  This means  
that while the browser is waiting for the server to return data the  
entire program hangs, something you probably noticed if you signed  
into hub yesterday. The solution is to convert all these pieces of  
code to a callback based model and make the XHR calls asynchronously.

I'd be happy to make this happen, but wanted to ping the list for  
comments and ideas on potential gotchas.

Thoughts?

-Travis


More information about the cosmo-dev mailing list