Tuesday, April 19, 2011

Ajax long connect using server heart beat to check client connect if it is closed

Using a trick HTTP response header

HTTP/1.1 200 OK
Server: xxx
Beat: Waiting.................................... // trick
Connection:Close
Content-length:255
Content-type:text/xml
Date:Wed Apr 20 12:01:17 EST 2011
Expires:Sun, 24 Apr 1981 01:29:32 GMT

Void Google Chrome pointer spinning for long Ajax connection

Put the request in a timer, or link, never directly put in page onload event

function onload() {
setTimeout(function() { // start ajax long connection in another thread to avoid google Chrome pointer spinning
doLongAjaxCallLoop ();
}, 3000);
}