Hello, I was wondering whether anybody would share a working example of a multiple html update on a single xmlhttprequest. Thank you in advance for your help. _________________________________________________________________ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
> I was wondering whether anybody would share a working example of a multiple > html update on a single xmlhttprequest. > > Thank you in advance for your help.Use RJS: http://rails.techno-weenie.net/tip/2005/11/29/ajaxed_forms_with_rjs_templates http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates -- rick http://techno-weenie.net
If you''re not using Rails, you can still achieve this by using Ajax.Request for your Ajax calls (not Ajax.Updater!), and send back a "Content-Type: text/ javascript" HTTP header, then just JavaScript in the response body (without "<script>" tags). This will cause Prototype to automatically evaluate the returned JavaScript so you can do multiple updates: $(''element'').innerHTML = ''this and that''; $(''anotherelement'').innerHTML = ''blah''; Of course, Rails makes that all much easier because stuff like correctly escaping chunks of HTML for JavaScript is build right in. -Thomas Am 21.12.2005 um 14:40 schrieb Rick Olson:>> I was wondering whether anybody would share a working example of a >> multiple >> html update on a single xmlhttprequest. >> >> Thank you in advance for your help. > > Use RJS: > > http://rails.techno-weenie.net/tip/2005/11/29/ > ajaxed_forms_with_rjs_templates > http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates > > > -- > rick > http://techno-weenie.net > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Marco M. Jaeger
2005-Dec-21 13:48 UTC
Re: ajax - multiple updates on single xmlhttprequest
Thanks for getting back to me - I''m afraid this is not helping me much, since I''m not using Rails. Thanks anyway _________________________________________________________________ Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/
Marco M. Jaeger
2005-Dec-21 13:56 UTC
Re: ajax - multiple updates on single xmlhttprequest
Is there a way to use xml or json somehow - if yes, how? has anybody done this before? _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it''s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Dirk Eschler
2005-Dec-22 09:55 UTC
Re: Re: ajax - multiple updates on single xmlhttprequest
Am Mittwoch, 21. Dezember 2005 14:56 schrieb Marco M. Jaeger:> Is there a way to use xml or json somehow - if yes, how? has anybody done > this before?I''ve successfully used JSON. Here''s a stripped down example: // --------------------------- // Handler function: is executed after successful Ajax.Request var handlerFunc = function(t) { // Evaluate returned JSON data var evalObj = eval(t.responseText); // Update info container $(''someId'').innerHTML = evalObj.foo; } // Bind the function and do the Ajax request new Ajax.Request(''script.pl'', { parameters: ''id=42'', onSuccess: handlerFunc }); // --------------------------- In the example "evalObj.foo" matches "({foo:"bla bla"})" in JSON. And "bla bla" will be written into the innerHTML part of the (X)HTML container with css id "someId". Hope that helps. Let me just add here, that i''m pretty new to script.aculo.us myself, so if anyone knows a better way of doing this, please let me know. Like the OP i''m looking for a good XML example without Rails too. -- Best Regards Dirk Eschler