Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13 rsolanki 1
<!--
2
 
3
var xmlHttp;
4
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
5
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
6
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
7
//netscape, safari, mozilla behave the same???
8
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
9
var ajaxdivname;
10
 
11
 
12
 
13
//stateChangeHandler will fire when the state has changed, i.e. data is received back
14
// This is non-blocking (asynchronous)
15
function stateChangeHandler()
16
{
17
 
18
    //readyState of 4 or 'complete' represents that data has been returned
19
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
20
        //Gather the results from the callback
21
        var str = xmlHttp.responseText;
22
 
23
        //Populate the innerHTML of the div with the results
24
		MM_findObj( ajaxdivname ).innerHTML = str;
25
    }
26
 
27
}
28
 
29
 
30
//stateComboChangeHandler will fire when the state has changed, i.e. data is received back
31
// This is non-blocking (asynchronous)
32
function stateComboChangeHandler()
33
{
34
	//Expected response data: text|-|value|-|selected|+|text2|-|value2|-|selected2
35
 
36
    //readyState of 4 or 'complete' represents that data has been returned
37
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
38
        //Gather the results from the callback
39
        var str = xmlHttp.responseText;
40
		var combo = ajaxdivname ;
41
		var lastOption = combo.options.length
42
 
43
        //Remove current Combo options
44
		for (i=0; i<lastOption; i++)
45
		{
25 rsolanki 46
			combo.options[0] = null;//The combo box re-organizes itself therefore remove the first element
13 rsolanki 47
		}
48
 
49
		//Populate combowith new items
50
		var optionArray = str.split('|+|');
51
 
52
		for (i in optionArray)
53
		{
54
			//alert(optionArray[i]);
55
			var opt = optionArray[i].split('|-|');
56
			combo.options[i] = new Option( opt[0], opt[1], opt[2] );
57
		}
58
 
59
 
60
    }
61
 
62
}
63
 
64
// XMLHttp send GET request
65
function xmlHttp_Get(xmlhttp, url) {
66
    xmlhttp.open('GET', url, true);
67
    xmlhttp.send(null);
68
}
69
 
29 jtweddle 70
// XMLHttp send GET request but wait for return;
71
function xmlHttp_Get_Synch(xmlhttp, url) {
72
    xmlhttp.open('GET', url, false);
73
    xmlhttp.send(null);
74
}
75
 
13 rsolanki 76
function GetXmlHttpObject(handler) {
77
    var objXmlHttp = null;    //Holds the local xmlHTTP object instance
78
 
3947 dpurdie 79
    if (typeof(handler) != "function") {
80
      alert('Internal: GetXmlHttpObject called without a handler');
81
      return;
82
    }
83
        //Depending on the browser, try to create the xmlHttp object
13 rsolanki 84
    if (is_ie){
85
        //The object to create depends on version of IE
86
        //If it isn't ie5, then default to the Msxml2.XMLHTTP object
87
        var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
88
 
89
        //Attempt to create the object
90
        try{
91
            objXmlHttp = new ActiveXObject(strObjName);
92
            objXmlHttp.onreadystatechange = handler;
93
        }
94
        catch(e){
95
        //Object creation errored
96
            alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
97
            return;
98
        }
99
    }
100
    else if (is_opera){
101
        //Opera has some issues with xmlHttp object functionality
102
        alert('Opera detected. The page may not behave as expected.');
103
        return;
104
    }
105
    else{
106
        // Mozilla | Netscape | Safari
107
        objXmlHttp = new XMLHttpRequest();
108
        objXmlHttp.onload = handler;
109
        objXmlHttp.onerror = handler;
110
    }
111
 
112
    //Return the instantiated object
113
    return objXmlHttp;
114
}
115
 
116
//-->