def ajax_request? request.env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' || params[:ajax] # params[:ajax] for safe-keeping, FIXME if it works w/ all browsers end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
ajax_request? method to XHR detection (See related posts)
Comments on this post
You need to create an account or log in to post comments to this site.
Related Posts
» Never render the full layout... in ruby rails javascript rubyonrails ajax programming jquery degradation degradable
» jQuery and Rails' respond_to in ruby rails javascript rubyonrails ajax js jquery respond_to
» Increase the number of simul... in firefox ajax xml xhr xmlhttprequest
» create a rails app from rail... in ruby rails shell svn bash subversion rubyonrails
» Extend FileColumn to work wi... in ruby rails rubyonrails
» Extend FileColumn to work wi... in ruby rails rubyonrails
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails
request.xhr?
The 'request' variable available in the controller can already tell you if it's an ajax request.