ajax - response.responseText adds previous responseText (node.js, prototype) -


यह मेरे node.js फ़ंक्शन है जो res.write का उपयोग करता है:

  function: ping () {Res.write (JSON.stringify ({"डेटा प्रकार": "पिंग"})); SetTimeout (पिंग, 30000); }   

यह ग्राहक है, प्रोटोटाइप में लिखित अनुरोध:

  this.pushconnection = new Ajax.Request (pushserveraddress, {method: 'get', EvalJSON: 'झूठी', इंटरैक्टिव पर: this.pushconnectionInteractive.bind (यह)}); } पुश कनेकशन इंटरैक्टिव: फ़ंक्शन (प्रतिक्रिया) {}   

समस्या यह है कि प्रतिक्रिया.प्रस्पतिक पाठ प्रत्येक res.write से बढ़ेगा के माध्यम से।

उदाहरण:

  1 पिंग () प्राप्त किया गया है: response.responseText = {"डेटाटाइप": "पिंग"} दूसरा पिंग () प्राप्त किया गया है: response.responseText = {"डेटा प्रकार": "पिंग"} {"डेटािंग": "पिंग"} 3 पिंग () प्राप्त किया गया है: response.responseText = {"डेटाटाइप": "पिंग"} {"डेटा प्रकार": "पिंग"} {"डेटा प्रकार" : "पिंग"}   

मुझे यकीन नहीं है कि नोड। जेएस डेटा फिर से भेज रहा है, या यदि प्रोटोटाइप डाटा जमा कर रहा है। मुझे response.responseText = res.end () का उपयोग किए बिना अंतिम डेटा भेजा गया है

आप शायद एक बार से अधिक this.pushconnection कॉल कर रहे हैं।

यदि आप this.pushconnection को अपनी Ajax ऑब्जेक्ट के रूप में इन्स्ताइज़ करते हैं और उसी एजेक्स ऑब्जेक्ट का उपयोग करना जारी रखते हैं, तो आपकी प्रतिक्रिया बढ़ेगी।

इसके बजाय इसे आज़माएं:

 < कोड> this.pushconnection = function (pushserveraddress) {नया अजाक्स। अनुरोध (पुशस्क्रेवार्डेड्रेस, {method: 'get', evalJSON: 'false', इंटरैक्टिव पर: this.pushconnectionInteractive.bind (this)}); }   

तब आप इसे कहकर कॉल कर सकते हैं:

  var ajax = this.pushconnection ("example.com");    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

javascript - What is an alternative to using getElementByClass for hiding multiple elements? -

php - Creating canonical URLs with custom route-classes -