LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > Ajax call is not interpreted as an ajax call

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2007, 12:29 AM
thbar thbar is offline
Member
 
Join Date: Sep 2006
Posts: 33
Default Ajax call is not interpreted as an ajax call

Hi!

I'm having an issue which only appears with LSWS. I have a rails 1.2 app on LSWS 2.2.2 with LSAPI (which also hosts another rails app). Everything works perfectly fine, except Ajax calls : they all render non-ajax versions of the pages. I have the feeling that the application does not receive one of the headers (maybe X-Requested-With).

Here are the typical headers sent by the client on these requests:

Request Headers
Host myapp.mydomain.fr
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
Accept text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
X-Prototype-Version 1.5.0
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Content-Length 0
Cookie ....
Pragma no-cache
Cache-Control no-cache


Did anyone meet this issue ?

Is there something to configure at LSWS level with regards to the headers ?

best regards

Thibaut
Reply With Quote
  #2  
Old 02-26-2007, 10:49 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Our rails easy configuration uses 404 handler to forward requests to backend Rails application, if there are both AJAX and non-AJAX version of pages for the same URL, the static version of the page will be served for sure.

To workaround this, you can use a vhost level rewrite rule to detect AJAX call by testing existence of "X-Requested-With" header.
Something like,

Code:
RewriteCond %{HTTP:X-Requested-With} !^$ 
RewriteRule  ^/  /dispatch.lsapi   [L]

Last edited by mistwang; 02-26-2007 at 11:12 AM..
Reply With Quote
  #3  
Old 02-26-2007, 03:38 PM
thbar thbar is offline
Member
 
Join Date: Sep 2006
Posts: 33
I've decided to try an upgrade and it worked! (without the rewriting work-around).

After upgrading from 2.2.2 to 2.2.6, and installing ruby-lsapi 2.0, everything is working fine.

Thanks for your work

Thibaut
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:24 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.