Friday, January 21, 2011

[Rails] Problem with relative URLs and AJAX requests.

Hello.

I have a Rails app (3.0.3) that uses jQuery (1.4.4) to do some AJAX
requests. For example, when doing a AJAX request on a page like
"http://localhost:3000/users/3" with
$("div#profile_box").load("profile");
the browser always tries to fetch from "http://localhost:3000/users/
profile". It simply ignores the "3".
But when adding a trailing slash after the 3 then it uses"http://
localhost:3000/users/3/profile".
Why does it not work without the trailing slash? I reproduced this
under Chrome and Firefox (not tried any other browser). And this seems
to be indeed a client side problem (I watch the request on the browser
console).
I know, this is not very Rails specific, but I already posted the
problem in the jQuery forum without receiving any explanation yet. And
I know there are a lot of Rails people using jQuery, so the above
scenario is nothing special.
How do you provide the URL to the jQuery AJAX functions? Do you have
the same problem? (I reproduced it also under another system.).

Regards,
Kai

--
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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate