1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*--------------------------------------------------------------------------------
AJAX Queue
----------------------------------------------------------------------------------*/
var AJAXQueue = new Array;
var AJAXServiceRunning=false;
var httpAjax = false;
/*--------------------------------------------------------------------------------
AjaxService
This is the only interface to the AJAX wrapper. This makes the ajax service
browser agnostic and provides a single interface for all of the services.
Each service uses a different url and a different parameter layout.
----------------------------------------------------------------------------------*/
function AjaxService(servicename,serviceparam){
AJAXQueue.push(servicename);
AJAXQueue.push(serviceparam);
if(!AJAXServiceRunning){
AJAXServiceRunning=true;
var Aparam=AJAXQueue.pop();
var Aservice=AJAXQueue.pop();
AjaxServiceExec(Aservice,Aparam);
}
}
/*--------------------------------------------------------------------------------
AjaxService
This is the only interface to the AJAX wrapper. This makes the ajax service
browser agnostic and provides a single interface for all of the services.
Each service uses a different url and a different parameter layout.
----------------------------------------------------------------------------------*/
function AjaxServiceExec(servicename,serviceparam){
// Parameters are set, initiate AJAX engine
if (window.XMLHttpRequest) {
httpAjax = new XMLHttpRequest();
if (httpAjax.overrideMimeType) {
httpAjax.overrideMimeType('text/xml');
}
}else if(window.ActiveXObject){
try{
httpAjax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
alert("CouldnŽt build an AJAX instance.");
return false;
}
}
}
// Send request to Server and initiate callback.
try{
httpAjax.onreadystatechange = getPage;
}catch(e){
// alert("onreadystatechange didnŽt go well!");
return false;
}try{
httpAjax.open('POST', servicename, true);
httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
}catch(e){
// alert("CouldnŽt open url.");
return false;
}try{
httpAjax.send(serviceparam);
}catch(e){
// alert("CouldnŽt send request.");
return false;
}
return true;
}
/*--------------------------------------------------------------------------------
getPage
This is the AJAX callback function. It detects the invoking service and handles
the reply from each service accordingly.
----------------------------------------------------------------------------------*/
function getPage() {
if(httpAjax.readyState == 4){
str=httpAjax.responseText;
if(AJAXQueue.length>0){
var Aparam=AJAXQueue.pop();
var Aservice=AJAXQueue.pop();
AjaxServiceExec(Aservice,Aparam);
}else{
AJAXServiceRunning=false;
}
return true;
}else{
// If any other ready state than prepared, do nothing!
}
}
|