The ajaxRails.js library is a layer on top of the base ajax.js library and only adds the necessary tricks for use with Rails applications. If you want to use this library then you must include it after including ajax.js in your document. When using this library the API for ajax.js doesn't change; however, the following behavior will be active.
The first two behaviors are for Rails RJS behavior. A request will automatically ask for JavaScript as it's first choice in response formats. If a response is JavaScript then the response body will automatically be evaluated with JavaScript's eval().
The last behavior is for Rails RESTful roots. This library allows users to use other HTTP verbs like "PUT", "DELETE" as used in Rails 1.2 with the same hack as used in Prototype.
The Fork Ajax library uses JavaScript's eval() function to automatically evaluate the server's response text if the Content-Type is set to text/javascript or application/javascript. This is inspired by the rjs facility built into Ruby on Rails and by Dan Webb's great Rails plugin ejs.
For more information about the implications of using eval() this way see the Mutate docs
Before Rails 1.2 the browser would make requests for an RJS response by setting the Accept header of the request to "text/javascript" followed by some other formats. The server then knows that an RJS response is desired by the browser. Unfortunately in Netscape Navigator 7.0 the XMLHttpRequest object is created with an Accept header which has text/html. When this library sets the Accept header it is appended to the original Accept header. So when the server looks at the Accept header it will see text/html before seeing text/javascript and so the server sends an html response if it can which is an undesirable result. In Rails 1.2 you can make the request with a format parameter ".js" at the end of the URL. The format parameter is used in preference to the Accept header so gets around this problem in Navigator 7.0 and possibly other browsers. Using the format parameter is a more robust option not just to support Navigator 7.0 but for other browsers that might do also create and XMLHttpRequest object with an Accept header.
Influenced by Prototype.