Topic: Weird problem: AJAX response has the RJS file content!!

Hey guys,

I'm struggling with quite a weird issue with AJAX that is driving me crazy. I have an AJAX-ified link that sends an AJAX request to my controller methods which oddly enough responds with the content of the RJS template instead of executing the java script!! the console output is pretty normal ( rendering RJS template XYZ etc) ... nothing seems to be wrong... no errors no whatsoever ....

i am on rails 3 rc 2..

The link code is :
link_to 'example', example_path, :remote => true

The RJS file content is: (this exact text is what is in the AJAX response)

page.replace_html 'examplediv', render :partial => 'example_partial'

so i tried responding from withing the controller and see what happens.....

format.js {
render :update |page| do
{
page.replace_html 'examplediv', render :partial => 'example_partial'
}
}

Oh, the partial is now output, but it doesn't update the div tag... the partial html code fills up the entire page html source!!

Please help me figure out what am doing wrong..

Re: Weird problem: AJAX response has the RJS file content!!

you might need to try format.rjs &block

Re: Weird problem: AJAX response has the RJS file content!!

Can you post the code in controller and the view? (both the link_to and the code in .rjs file)

Giang, Nguyen Duc
Email: ndgiang84@gmail.com
Website: http://xiga.info
Please recommend for me on WorkingWithRails if you find my post useful: http://workingwithrails.com/person/1849 … -duc-giang

Re: Weird problem: AJAX response has the RJS file content!!

try removing the "render"

page.replace_html 'examplediv', :partial => 'example_partial'

Firebait

Last edited by firebait (2010-10-26 09:03:44)