js file.
var xhr = false;
var dgbcnt = 0;
// preload loading image
loading = new Image();
loading.src = "assets/loading.gif";
function dbg(message){
dgbcnt ++;
var messobj = document.getElementById('debug');
if(messobj) messobj.innerHTML += dgbcnt+': '+message+'
';
}
function TestXHR(){
// check for XHR support
var xhrsupport = XHRInit();
if(xhrsupport){
return true;
}
return false;
Chapter 10
[ 187 ]
}
function XHRInit() {
if(xhr){ return "true 1"; }
else {
req = false;
if(window.XMLHttpRequest) {
try { xhr = new XMLHttpRequest(); return
"XMLHttpRequest Object"; }
catch(e) { xhr = false; return false; }
return false;
} else if(window.ActiveXObject) {
try { xhr = new ActiveXObject('Msxml2.XMLHTTP');
return "ActiveX"; }
catch(e) {
try {xhr = new ActiveXObject('Microsoft.XMLHTTP');
return "ActiveX";} catch(e) { xhr = false;
return false; }
}
return false;
} else { xhr = false; return false; }
}
}
function XHReq(url, responsediv, addcontent, returnvalue){
if(XHRInit()){
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'text/html;
charset=utf-8');
xhr.onreadystatechange = function(){ if(xhr.
Pages:
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253