לאתר זה תהיה פונקציונליות מוגבלת בזמן שאנו מתחזקים אותו לשיפור החוויה שלך. אם מאמר מסויים לא פותר את הבעיה שלך וברצונך לשאול שאלה, קהילת התמיכה שלנו מחכה לעזור לך ב־Twitter תחת ‎@FirefoxSupport וב־Reddit תחת ‎/r/firefox.

חיפוש בתמיכה

יש להימנע מהונאות תמיכה. לעולם לא נבקש ממך להתקשר או לשלוח הודעת טקסט למספר טלפון או לשתף מידע אישי. נא לדווח על כל פעילות חשודה באמצעות באפשרות ״דיווח על שימוש לרעה״.

מידע נוסף

xmlHttpRequest AJAX not returning message from COMET server

more options

I have the following COMET client javascript code:


          function getResponse() {
               document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.
"; if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("GET", "http://L45723:1802?callback=testcallback", true); //must use this URL at work. receiveReq.onreadystatechange = handleReceiveMessage; alert("handleReceiveMessage assigned to onreadystatechange event."); receiveReq.overrideMimeType("text/x-json"); receiveReq.timeout = 100000; var currentDate = new Date(); var sendMessage = JSON.stringify({ SendTimestamp: currentDate, Message: "Message 1", Browser: navigator.appName, OriginUrl: document.URL }); var sendMessage = "SendTimestamp=" + currentDate + "&Message=Message1&Browser=" + navigator.userAgent; alert("JSON message created. About to send..."); receiveReq.send(sendMessage); alert("Message sent.");
               }
           }
           //function for handling the return message from Comet
           function handleReceiveMessage() {
               document.getElementById("_receivedMsgLabel").innerHTML += "Status=" + receiveReq.status;
               document.getElementById("_receivedMsgLabel").innerHTML += "responseText=" + receiveReq.responseText;
               
               if (receiveReq.readyState == 4 && receiveReq.status == 200) {
                   document.getElementById("_receivedMsgLabel").innerHTML += "Message received!
"; var status = receiveReq.status; var txt = receiveReq.responseText; document.getElementById("_receivedMsgLabel").innerHTML += txt + "
"; mTimer = setTimeout("getResponse();", 0); }
               getResponse();
           }

The GET request is sent and received by the COMET server, which sends the response back when I choose to. The handleReceiveMessage() function is called, but the message the server sent is not in the xmlHttpRequest.responseText property.

Why?

I have the following COMET client javascript code: function getResponse() { document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.<br/>"; if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("GET", "http://L45723:1802?callback=testcallback", true); //must use this URL at work. receiveReq.onreadystatechange = handleReceiveMessage; alert("handleReceiveMessage assigned to onreadystatechange event."); receiveReq.overrideMimeType("text/x-json"); receiveReq.timeout = 100000; var currentDate = new Date(); var sendMessage = JSON.stringify({ SendTimestamp: currentDate, Message: "Message 1", Browser: navigator.appName, OriginUrl: document.URL }); var sendMessage = "SendTimestamp=" + currentDate + "&Message=Message1&Browser=" + navigator.userAgent; alert("JSON message created. About to send..."); receiveReq.send(sendMessage); alert("Message sent."); } } //function for handling the return message from Comet function handleReceiveMessage() { document.getElementById("_receivedMsgLabel").innerHTML += "Status=" + receiveReq.status; document.getElementById("_receivedMsgLabel").innerHTML += "responseText=" + receiveReq.responseText; if (receiveReq.readyState == 4 && receiveReq.status == 200) { document.getElementById("_receivedMsgLabel").innerHTML += "Message received!<br/>"; var status = receiveReq.status; var txt = receiveReq.responseText; document.getElementById("_receivedMsgLabel").innerHTML += txt + "<br/>"; mTimer = setTimeout("getResponse();", 0); } getResponse(); } The GET request is sent and received by the COMET server, which sends the response back when I choose to. The handleReceiveMessage() function is called, but the message the server sent is not in the xmlHttpRequest.responseText property. Why?

כל התגובות (1)

more options

I suggest continuing the discussion in your thread on mozillaZine, since this site focuses more on end-user support.

xmlHttpRequest object - mozillaZine Forums