Hello all is it possible? I have a select list, and "onchange" event i am using a remote_function, when it is completed, I wanted to execute a javascript: $(this).next(.''product_price'').value "RESPONSE_TEXT_FROM_AJAX_REQUEST" there is some way to do this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jul-20 21:16 UTC
Re: How to get the responseText from an Ajax.request (urgent!)
On Jul 20, 9:52 pm, flaubert <aflaube...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello all > > is it possible? > I have a select list, and "onchange" event i am using a > remote_function, when it is completed, I wanted to execute a > javascript: $(this).next(.''product_price'').value > "RESPONSE_TEXT_FROM_AJAX_REQUEST" >supply an onComplete or an onSuccess handler, eg :complete => ''...'' what you give will be wrapper in a function declaration where request will be the request that completed (and so request.responseText is what the server rendered). Just check that ''this'' is what you think it is Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip
2008-Jul-20 21:21 UTC
Re: How to get the responseText from an Ajax.request (urgent!)
flaubert wrote:> I have a select list, and "onchange" event i am using a > remote_function, when it is completed, I wanted to execute a > javascript: $(this).next(.''product_price'').value > "RESPONSE_TEXT_FROM_AJAX_REQUEST" > > there is some way to do this?An alternative to the other answer - don''t reply with raw text. Write your action like this: def action result = whatever(params) render :update do |rjs| rjs.replace_html :product_price, convert_to_html(result) end end I don''t know how convert_to_html will convert your result; its return value must be a string of well-formed HTML. The benefit is you do all this on the server side, so the resulting Javascript is more likely to work with more browsers. -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---