How to get the responseText from an Ajax.request (urgent!)

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?

On Jul 20, 9:52 pm, flaubert [email protected] 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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs