Little jQuery hook that extends AJAX IO for Rails applications. It adds the following:
On Send:
-
scrapes the page for the csrf-token meta tag to transparently send those params down with each request in the X-CSRF-Token header.
-
adds X-Referrer-Url which includes the anchor/hash portion of the URL that standard referrer misses
On Receive:
-
looks for an X-Callback-Url header in the response and, if found, will add that as a param (after the url anchor - this is oriented towards applications with client-managed routes). this is useful if you are, for example, rendering a login page that logs in via ajax and need to communicate the post-login client-side route to the client.
-
if the response is a 301 or 302, looks for an X-Hash-Location header in the response and, if found, will change the anchor/hash portion of the existing route to the new location. basically like the Location header of a standard 30x redirect only for client-managed routes.
-
if the response is a 301 or 302, looks for the Location header in the response and, if found, will follow the redirect like a non-ajax 301 or 302 would