Die Funktionalität dieser Website ist durch Wartungsarbeiten eingeschränkt, die Ihr Erlebnis verbessern sollen. Wenn ein Artikel Ihr Problem nicht löst und Sie eine Frage stellen möchten, können Sie unsere Gemeinschaft über @FirefoxSupport auf Twitter, /r/firefox oder Reddit fragen.

Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

Ajax call returns 200 in IE but 0 in firefox 3.6.8

  • 3 Antworten
  • 143 haben dieses Problem
  • 1 Aufruf
  • Letzte Antwort von TimeWarDoctor

more options

firefox gets a xmlHttpRequest status 0 for the ajax call for which IE6 get a 200 . The code runs perfectly under IE6. fails (xmlhttprequest==200) in ajax

This happened

Every time Firefox opened

== testing ajax code

firefox gets a xmlHttpRequest status 0 for the ajax call for which IE6 get a 200 . The code runs perfectly under IE6. fails (xmlhttprequest==200) in ajax == This happened == Every time Firefox opened == testing ajax code

Alle Antworten (3)

more options

Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. http://forums.mozillazine.org/viewforum.php?f=25 You'll need to register and login to be able to post in that forum.

more options

In Firefox, you cannot request other websites (websites that do not use relative path, like http://www.google.com) on client side.

more options

I got the same issue, but with Firefox 12. I use this code to call my COMET server:


           function getXmlHttpRequestObject() {
               if (window.XMLHttpRequest) {
                   //document.getElementById("_receivedMsgLabel").innerHTML += "Non-microsoft xmlHttpRequest object created.
"; alert("Non-microsoft xmlHttpRequest object created."); return new XMLHttpRequest(); } else if (window.ActiveXObject) { //document.getElementById("_receivedMsgLabel").innerHTML += "Microsoft xmlHttpRequest object created.
"; alert("Microsoft xmlHttpRequest object created."); return new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Status: Could not create XmlHttpRequest Object. Consider upgrading your browser."); //document.getElementById("_receivedMsgLabel").innerHTML += "Status: Could not create XmlHttpRequest Object. Consider upgrading your browser.
"; } }
           var sendReq = getXmlHttpRequestObject();
           var receiveReq = getXmlHttpRequestObject();
           var lastMessage;
           var mTimer;
           //Gets the server response:
           function getResponse() {
               document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.
"; if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { //if (receiveReq.readyState == 0) { //receiveReq.open("POST", 'http://tardis:1802', true, "server", "server123"); //receiveReq.open("POST", 'http://localhost:1802', true, "server", "server123"); //receiveReq.open("POST", 'http://holit109:1802', true, "server", "server123"); //receiveReq.open("POST", "http://localhost:1802", true, "server", "server123"); receiveReq.open("POST", "http://L45723:1802", true, "server", "server123"); //must use this URL at work. receiveReq.onreadystatechange = handleReceiveMessage; alert("handleReceiveMessage assigned to onreadystatechange event."); receiveReq.setRequestHeader("Content-Type", "text/x-json"); receiveReq.timeout = 0; var currentDate = new Date(); var sendMessage = JSON.stringify({ SendTimestamp: currentDate, Message: "Message 1", Browser: navigator.appName }); //receiveReq.send("<Request><Command>Queue</Command><User>user1</User><Message>Message 1</Message><Message>Message 2</Message><Message>Message 3</Message></Request>"); alert("JSON message created. About to send..."); receiveReq.send(sendMessage); alert("Message sent.");
               }
           }
           //function for handling the return message from Comet
           function handleReceiveMessage() {
               if (receiveReq.readyState == 4) {
                   document.getElementById("_receivedMsgLabel").innerHTML += "Message received!
"; var status = receiveReq.status; //document.getElementById("_receivedMsgLabel").innerHTML += "Status received!
"; var txt = receiveReq.responseText; var receivedMsg = JSON.parse(txt); document.getElementById("_receivedMsgLabel").innerHTML += receivedMsg.Message + "
"; //var receivedTime = new Date(); //alert("Got current date."); //alert(receivedTime); //var receivedTime_ms = receivedTime.getTime(); //alert("Got time message received in ms."); //alert(receiveReq.SendTimestamp); //var sentTime_ms = getDateFromFormat(receiveReq.SendTimestamp, "dd/MM/yyyy HH:mm:ss"); //var sentTime = new Date(receiveReq.SendTimestamp); //alert("Got time message sent in ms."); //var sentTime_ms = sentTime.getTime(); //var difference_ms = receivedTime_ms - sentTime_ms; //document.getElementById("_receivedMsgLabel").innerHTML += "Comet took " + difference_ms + " ms.
";
                   mTimer = setTimeout("getResponse();", 0);
               }
               getResponse();
           }

The handleReceiveMessage() event handler is called, but there is no data returned in the responseText property of the xmlHttpRequest object.

Why?

This works fine in IE9.