Conflict with squid and ajax

I have a user who receives an error from ajax calls on our website.

The error will be inserted below.

They get the error on Windows FF3 but not IE.

Based on some searching, it seems that this problem is often caused by the client protocol calcium (you'll notice at the end of the error, squid is mentioned).

My ajax code is used here: http://www.w3schools.com/Ajax/ajax_browsers.asp

Any ideas?

ERROR

The requested URL could not be retrieved

While trying to process the request:

POST /library/cart/cart_ajax.php?action=refreshCartWidget&qty=dontuse& HTTP/1.1
Host: mydomain.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (.NET CLR 3.5.30729)

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: identity,gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300

Connection: Close
Referer: http://mydomain.com/library

Pragma: no-cache
Cache-Control: no-cache

The following error was encountered:

Invalid Request
Some aspect of the HTTP Request is invalid. Possible problems:

Missing or unknown request method
Missing URL
Missing HTTP Identifier (HTTP/1.0)
Request is too large
Content-Length missing for POST or PUT requests
Illegal character in hostname; underscores are not allowed
Your cache administrator is webmaster. 
Generated Wed, 12 Nov 2008 09:28:58 GMT by ipwal3.osi-tech.com (squid/2.6.STABLE17)

      

0


source to share


3 answers


Save some time and use jQuery . It has an abstraction for ajax that works in all browsers, not just Internet Explorer and possibly FF. ;-) My guess is that the code there is old and hasn't been updated in a long time.

A simple ajax call in jQuery looks like this:

$.post(
  '/the/url/to/post/to',
  { some: data },
  function(data) { alert(data); }
);

      



It also helps if you understand the basics of HTTP - for example, the query methods ( PUT

, POST

, GET

, DELETE

, HEAD

) and so on. The error you inserted means that the header is Content-Length

missing with your request, and most (if not all) servers expect it to be sent on release PUT

or POST

as it is assumed to be a "data change" (eg create, update).

IE may be adding the header for you, but Firefox apparently doesn't.

jQuery will take care of all of this.;)

+2


source


You can use .setRequestHeader () on your XHR object to set the length of the content if FF doesn't do it for you.



Since you are sending your data in the .send (content) method, just add the header before that with content.length.

+1


source


You have to sit with your user and put Fiddler's HTTP tracking tool in between. Then you can easily compare the request sent by IE and FF3.

So it should become visible where the differences are and why they are causing problems.

0


source







All Articles