Thursday, April 20, 2006

Creating a Synchronous call using Prototype

Tried to make a Synchronous Ajax call using the Script.aculo.us Library. Damn how do you do it ?
new Ajax.Request('/foo/bar', {asynchronous:true});
Looking at the code, setting the 'asynchronous' flag to 'false' should do the trick. Unfortunately, this does not seem to work.

new Ajax.Request('/foo/bar', {asynchronous:false});
Wierd

But got a chance to peek into prototype.js. Wow. Javascript can be beautiful.

2 Comments:

Blogger nishant said...

I was saved with the same problem, digging deeper into prototype i came up with something that works .. although i dont know if this is the right way of doing it

var myAjax = new Ajax.Request( url, { method: 'get',parameters: pars, asynchronous:false });

alert(myAjax.transport.responseText);

8:37 AM  
Anonymous Anonymous said...

Yup, had the same problem myself, I added method:"get" before my onSuccess or onFailure and my ajax calls worked. Oddly enough I didn't have this problem running on my local server. Tootired to figure out why.

12:27 AM  

Post a Comment

<< Home