problème ajax firefox

Eléphant du PHP | 124 Messages

05 févr. 2008, 12:37

Salut,

J'ai un script ajax permettant de refresh des requetes SQL.

Ce script fonctionne sous Internet Explorer mais pas sous Firefox, j'obtient l'erreur suivante :
While trying to process the request:

POST ajax/ajax.php HTTP/1.1
Host: www.[...].fr
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.[...]/ajax/refresh.php
Authorization: Basic a2hsZW86bXBveng=
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 a@localhost.
Script ajax :

Code : Tout sélectionner

function refresh_div() { var xhr_object = null; if(window.XMLHttpRequest) { // Firefox xhr_object = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer xhr_object = new ActiveXObject('Microsoft.XMLHTTP'); } else { // XMLHttpRequest non supporté par le navigateur alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); xhr_object = false; } var method = 'POST'; var filename = 'ajax.php'; xhr_object.open(method, filename, true); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { var tmp = xhr_object.responseText; document.getElementById('hey').innerHTML = tmp; } } xhr_object.send(null); setTimeout('refresh_div()', 10000); }
Modifié en dernier par neo765 le 29 mai 2008, 15:17, modifié 1 fois.

Eléphant du PHP | 445 Messages

05 févr. 2008, 17:07

Content-Length missing for POST or PUT requests
Si tu n'envoie pas de données, preferes plutot GET qui ne te forcera pas à mettre un Content-Length.

Eléphant du PHP | 124 Messages

06 févr. 2008, 00:33

Re,

Bizarre, je viens te tester le script sur plusieurs pc avec firefox et le problème n'est plus :s.

Le problème est uniquement visible sur les firefox des pc de mon école.