diff options
author | Pim van den Berg | 2009-12-05 20:23:25 +0100 |
---|---|---|
committer | Pim van den Berg | 2009-12-05 20:23:25 +0100 |
commit | 1a076098050969d217f7abe8ec2102719fcba21d (patch) | |
tree | a44dedb92ce9687b5465963292de427dc08d0dd6 /ajax.js | |
parent | temporary disable swap_io (diff) | |
download | apt-panopticon_cgp-1a076098050969d217f7abe8ec2102719fcba21d.zip apt-panopticon_cgp-1a076098050969d217f7abe8ec2102719fcba21d.tar.gz apt-panopticon_cgp-1a076098050969d217f7abe8ec2102719fcba21d.tar.bz2 apt-panopticon_cgp-1a076098050969d217f7abe8ec2102719fcba21d.tar.xz |
load plugins on the host page via ajax
Diffstat (limited to 'ajax.js')
-rw-r--r-- | ajax.js | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -0,0 +1,47 @@ | |||
1 | function getP(host, plugin) { | ||
2 | getData(host, plugin, 'load'); | ||
3 | } | ||
4 | |||
5 | function rmP(host, plugin) { | ||
6 | getData(host, plugin, 'del'); | ||
7 | } | ||
8 | |||
9 | var xmlHttp | ||
10 | |||
11 | function getData(obj, id, action) { | ||
12 | xmlHttp=GetXmlHttpObject(); | ||
13 | if (xmlHttp==null) { | ||
14 | alert ("Your browser does not support AJAX!"); | ||
15 | return; | ||
16 | } | ||
17 | |||
18 | var url="plugin.php"; | ||
19 | url=url+"?h="+obj+"&p="+id+"&a="+action; | ||
20 | xmlHttp.onreadystatechange=function(){setData(id)} | ||
21 | xmlHttp.open("GET",url,true); | ||
22 | xmlHttp.send(null); | ||
23 | } | ||
24 | |||
25 | function setData(obj) { | ||
26 | if (xmlHttp.readyState==4) { | ||
27 | div = document.getElementById(obj); | ||
28 | |||
29 | div.innerHTML=xmlHttp.responseText; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function GetXmlHttpObject() { | ||
34 | var xmlHttp=null; | ||
35 | try { | ||
36 | // Firefox, Opera 8.0+, Safari | ||
37 | xmlHttp=new XMLHttpRequest(); | ||
38 | } catch (e) { | ||
39 | // Internet Explorer | ||
40 | try { | ||
41 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); | ||
42 | } catch (e) { | ||
43 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); | ||
44 | } | ||
45 | } | ||
46 | return xmlHttp; | ||
47 | } | ||