Hi Folks,

I'm wondering if there is a way to get a function to wait until an
external Ajax.Request has completed.  As always, I find an example is
the best way to describe my issue:

var buildPage = {};
buildPage = Class.create();
buildPage.prototype =
{
initialize: function() {
this.RS = [];//hold json data for later use
 ...
this._getData(1);
},
_getData : function(a) {
var url = (a==1) ? 'url1' : 'url2';
new Ajax.Request (url), {method:'get',
onSuccess  : function(transport){
    this.RS = transport.responseText.evalJSON();
    if (a==1) this._drawPage;
  });
},
_drawPage : function () {
//parse this.RS data with template
...
},
_refreshData : function () {
 this.getData(2);
//wait until _getData reports success then continue
 this._drawPage();
}
};

So this buildPage class reuses the _getData method calling a different
URL depending on what is passed to it.  What I want the _refreshData
method to do is call the _getData method, and only when it has
successfully refreshed the RS array, call the _drawPage method.

Is this possible? should I be doing it a different way?

Many thanks

George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to