I had one point in my project where I needed a synchronous Ajax call; in other words, I wanted the Ajax.Updater call to not return until the content of my page had been updated. However, I found that if you call Ajax.Updaterwith the {asynchronous: false} option, the onComplete() function would never be called and your content would not be updated. Was this the intended behavior? I added the following lines of code to the end of the request function and it now behaves as I would expect it to, but I wanted to see if anyone was relying on the old behavior before I submitted a patch: if( !this.options.asynchronous ) this.options.onComplete(); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050817/4539daa4/attachment.html
Don''t use this option. It will completely block your browser (it will seem ''dead'' as in ''crashed'' to the user). Can you describe the problem/situation where you need this? Maybe there''s a better way to do it. -- Thomas Am 17.08.2005 um 17:58 schrieb Dillon Woods:> I had one point in my project where I needed a synchronous Ajax > call; in other words, I wanted the Ajax.Updater call to not return > until the content of my page had been updated. However, I found > that if you call Ajax.Updater with the {asynchronous: false} > option, the onComplete() function would never be called and your > content would not be updated. Was this the intended behavior? I > added the following lines of code to the end of the request > function and it now behaves as I would expect it to, but I wanted > to see if anyone was relying on the old behavior before I submitted > a patch: > if( !this.options.asynchronous ) > this.options.onComplete(); > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
On 8/17/05, Thomas Fuchs <thomas@fesch.at> wrote:> Can you describe the problem/situation where you need this? Maybe > there''s a better way to do it.I basically have two lists of data, the contents of the second list depend on the item selected in the first list. When the page initially loads there are two Ajax calls to load the two lists; the problem is, if the calls are asynchronous, loading the second list will sometimes result in an error since the first list doesn''t necessarily exist yet. By making the first call synchronous, the browser will block and exhibit the "dead" behavior until the first list is created, and then it will let the second request go as normal. Creating the first list doesn''t take very long, and I change the contents to a "Loading" icon while it is loading, so I don''t really mind the blocking behavior. Doesn''t the asynchronous option exist for situations like this? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050817/f7c8269d/attachment.html
I assume you use Rails. Besides that in this case you shouldn''t use AJAX (but simply include the elements on your "original" page), you can use :complete => ''(second AJAX request)'' to accomplish this. No need for synchronous requests. Also, you can update more than one element with an AJAX call by sending back JavaScript from the server and using :complete => evaluate_remote_response. See update_element_function at http:// api.rubyonrails.com/classes/ActionView/Helpers/ JavaScriptHelper.html#M000399 for more on this. Thomas Am 17.08.2005 um 19:28 schrieb Dillon Woods:> On 8/17/05, Thomas Fuchs <thomas@fesch.at> wrote: > Can you describe the problem/situation where you need this? Maybe > there''s a better way to do it. > > I basically have two lists of data, the contents of the second list > depend on the item selected in the first list. When the page > initially loads there are two Ajax calls to load the two lists; the > problem is, if the calls are asynchronous, loading the second list > will sometimes result in an error since the first list doesn''t > necessarily exist yet. By making the first call synchronous, the > browser will block and exhibit the "dead" behavior until the first > list is created, and then it will let the second request go as > normal. Creating the first list doesn''t take very long, and I > change the contents to a "Loading" icon while it is loading, so I > don''t really mind the blocking behavior. Doesn''t the asynchronous > option exist for situations like this? > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050817/1eb8ff9e/attachment.html
Thomas- How would you return javascript to use on the page with just plain old HTML without using rails? I am just using the prototype JS library. Thanks. On 8/17/05, Thomas Fuchs <thomas@fesch.at> wrote:> > I assume you use Rails. > > Besides that in this case you shouldn''t use AJAX (but simply include the > elements on your "original" page), you can use :complete => ''(second AJAX > request)'' to accomplish this. No need for synchronous requests. > > Also, you can update more than one element with an AJAX call by sending > back JavaScript from the server and using :complete => > evaluate_remote_response. See update_element_function at > http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000399for more on this. > > Thomas > Am 17.08.2005 um 19:28 schrieb Dillon Woods: > > On 8/17/05, Thomas Fuchs <thomas@fesch.at> wrote: > > > Can you describe the problem/situation where you need this? Maybe > > there''s a better way to do it. > > > I basically have two lists of data, the contents of the second list depend > on the item selected in the first list. When the page initially loads there > are two Ajax calls to load the two lists; the problem is, if the calls are > asynchronous, loading the second list will sometimes result in an error > since the first list doesn''t necessarily exist yet. By making the first call > synchronous, the browser will block and exhibit the "dead" behavior until > the first list is created, and then it will let the second request go as > normal. Creating the first list doesn''t take very long, and I change the > contents to a "Loading" icon while it is loading, so I don''t really mind the > blocking behavior. Doesn''t the asynchronous option exist for situations like > this? > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Eric Fleming efleming@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050818/3e271056/attachment-0001.html
Nevermind, should have just done a little searching on this subject. Looked through the source of rails and found that all you have to do is put an eval() around the reponse. Worked great, thanks for the great resources. On 8/18/05, Eric Fleming <efleming@gmail.com> wrote:> > Thomas- > > How would you return javascript to use on the page with just plain old > HTML without using rails? I am just using the prototype JS library. Thanks. > > On 8/17/05, Thomas Fuchs <thomas@fesch.at> wrote: > > > > I assume you use Rails. > > > > Besides that in this case you shouldn''t use AJAX (but simply include the > > elements on your "original" page), you can use :complete => ''(second AJAX > > request)'' to accomplish this. No need for synchronous requests. > > > > Also, you can update more than one element with an AJAX call by sending > > back JavaScript from the server and using :complete => > > evaluate_remote_response. See update_element_function at > > http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000399for more on this. > > > > Thomas > > Am 17.08.2005 um 19:28 schrieb Dillon Woods: > > > > On 8/17/05, Thomas Fuchs < thomas@fesch.at> wrote: > > > > > Can you describe the problem/situation where you need this? Maybe > > > there''s a better way to do it. > > > > > > I basically have two lists of data, the contents of the second list > > depend on the item selected in the first list. When the page initially loads > > there are two Ajax calls to load the two lists; the problem is, if the calls > > are asynchronous, loading the second list will sometimes result in an error > > since the first list doesn''t necessarily exist yet. By making the first call > > synchronous, the browser will block and exhibit the "dead" behavior until > > the first list is created, and then it will let the second request go as > > normal. Creating the first list doesn''t take very long, and I change the > > contents to a "Loading" icon while it is loading, so I don''t really mind the > > blocking behavior. Doesn''t the asynchronous option exist for situations like > > this? > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > -- > Eric Fleming > efleming@gmail.com-- Eric Fleming efleming@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050818/62495b66/attachment.html