OK,
i guess passing callback itself is the only way (because of the
event/listener model of javascript):
function call(callback){
$.get('/c-FavoritesPanel',function(data){
//data is definetely initialized here now
callback(data);
});
}
aldana wrote:
>
> hi i got a function, which calls ajax way. problem is that the function
> should only return after the ajax call is completed. otherwise i could end
> up with unitialized data. how can i simulate such a thing with jquery? or
> is the usual way to pass another callback function to the call() method
> and place it inside the passed .$get function (something like callback
> chaining)?
>
> i guess a drawback from blocking would be that the javascript process
> would halt for the ajax-call (javascript only has one execution path).
>
> code:
> function call(){
> var value;
> $.get('/c-FavoritesPanel',function(data){
> value = data;
> });
> //could be null (.$get only adds callback and does not wait until ajax
> completed)
> return value;
> }
>
-----
manuel aldana
aldana((at))gmx.de
software-engineering blog: http://www.aldana-online.de
--
View this message in context:
http://www.nabble.com/simulating-blocking-%24.get-tp21583622s27240p21583730.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.