-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.js
47 lines (40 loc) · 908 Bytes
/
ajax.js
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
function getP(host, plugin) {
getData(host, plugin, 'load');
}
function rmP(host, plugin) {
getData(host, plugin, 'del');
}
var xmlHttp
function getData(obj, id, action) {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
return;
}
var url="plugin.php";
url=url+"?h="+obj+"&p="+id+"&a="+action;
xmlHttp.onreadystatechange=function(){setData(id)}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function setData(obj) {
if (xmlHttp.readyState==4) {
div = document.getElementById(obj);
div.innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}