Ajax request gets to server but page doesn't update - Rails, jQuery
- by Jesse
So I have a scenario where my jQuery ajax request is hitting the server, but the page won't update. I'm stumped...
Here's the ajax request:
$.ajax({
type: 'GET',
url: '/jsrender',
data: "id=" + $.fragment().nav.replace("_link", "")
});
Watching the rails logs, I get the following:
Processing ProductsController#jsrender (for 127.0.0.1 at 2010-03-17 23:07:35) [GET]
Parameters: {"action"=>"jsrender", "id"=>"products", "controller"=>"products"}
...
Rendering products/jsrender.rjs
Completed in 651ms (View: 608, DB: 17) | 200 OK [http://localhost/jsrender?id=products]
So, it seems apparent to me that the ajax request is getting to the server. The code in the jsrender method is being executed, but the code in the jsrender.rjs doesn't fire. Here's the method, jsrender:
def jsrender
@currentview = "shared/#{params[:id]}"
respond_to do |format|
format.js {render :template => 'products/jsrender.rjs'}
end
end
For the sake of argument, the code in jsrender.rjs is:
page<<"alert('this works!');"
Why is this? I see in the params that there is no authenticity_token, but I have tried passing an authenticity_token as well with the same result.
Thanks in advance.