jQuery AJAX request (Rails 3) gets redirected and returns empty message body (only with SSL)!
- by elsurudo
I'm trying to do a manual jQuery AJAX request the following way:
$("#user_plan_id").change(function() {
$("#plan_container").load('/plans/' + this.value);
});
I have the "rails.js" file included in my header, and a "<%= csrf_meta_tag %".
I see from my log that the request IS getting to the server (although without the authenticity token... does rails.js even do this?), but the response is a 302 (Found) rather than 200, and no data actually gets rendered.
Any ideas?
Edit: I now see that the first request redirects, and the proper partial gets rendered on the redirect. However, the 2nd response's body (on the client-side) is still empty. I'm guessing jQuery uses the first response and doesn't have a listener set up for the redirect. How do I get around this?
Also, another note: the page doing the requesting is an HTTPS page.
Here is what my log says:
Started GET "/plans/221168073" for 127.0.0.1 at Tue Jun 15 01:24:06 -0400 2010
Processing by PlansController#show as HTML
Parameters: {"id"=>"221168073"}
DEPRECATION WARNING: Using #request_uri is deprecated. Use fullpath instead. (called from ensure_proper_protocol at /Users/ernestsurudo/Sites/vidfolia/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb:57)
Redirected to http://vidfolia.com/plans/221168073
Completed 302 Found in 1ms
It turns out that if I turn off SSL requirement for that page, it works! I still have no idea why, though. So I suppose my question is: what is the workaround?