diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-13 23:13:19 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-13 23:13:19 +0000 |
commit | d62b6301752354c2a26e9f82b0846c490a4dba37 (patch) | |
tree | db8b39f79bf30546de4b01b607309502d27b5228 | |
parent | 859fa01c1be7b5a5ab2408db874ed11967a7b552 (diff) | |
download | ampache-d62b6301752354c2a26e9f82b0846c490a4dba37.tar.gz ampache-d62b6301752354c2a26e9f82b0846c490a4dba37.tar.bz2 ampache-d62b6301752354c2a26e9f82b0846c490a4dba37.zip |
breaking all ajax... but its for the best
-rwxr-xr-x | modules/kajax/ajax.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/modules/kajax/ajax.js b/modules/kajax/ajax.js index ea008ba3..eb80d75e 100755 --- a/modules/kajax/ajax.js +++ b/modules/kajax/ajax.js @@ -2,8 +2,10 @@ // All Rights Reserved
// Origional Author: Kevin Riker
// Added Multi-Value XML based GET/POST replacement * Karl Vollmer
+// Added Auto-Detects source/target information based on XML Doc Elements and
+// Form Elements if it's a post call * Karl Vollmer
// Licensed under the GNU/GPL
-
+
var http_request = false;
var IE = true;
@@ -32,7 +34,7 @@ }
// uid is an array of uids that need to be replaced
- function ajaxPut(url,uid) {
+ function ajaxPut(url) {
if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
@@ -51,7 +53,7 @@ if (!http_request) {
return false;
}
- http_request.onreadystatechange = function() { getContents(http_request,uid); };
+ http_request.onreadystatechange = function() { getContents(http_request); };
http_request.open('GET', url, true);
http_request.send(null);
}
@@ -59,20 +61,26 @@ function getContents(http_request,uid) {
if (http_request.readyState == 4) {
data = http_request.responseXML;
- for(i=0;i<uid.length;i++) {
- var new_txt = data.getElementsByTagName(uid[i])[0].firstChild.nodeValue;
- document.getElementById(uid[i]).innerHTML = new_txt;
+ for(i=0;i<data.childNodes[0].childNodes.length;i++) {
+ if (data.childNodes[0].childNodes[i].nodeType == '1') {
+ var txt_node = data.childNodes[0].childNodes[i];
+ var new_txt = txt_node.firstChild.nodeValue;
+ document.getElementById(txt_node.localName).innerHTML = new_txt;
+ }
}
}
}
- function ajaxPost(url,input,output) {
+ function ajaxPost(url,input) {
var post_data = 'a=0';
-
- for(i=0;i<input.length;i++) {
- post_data = post_data +'&' + input[i] + '=' + encodeURI(document.getElementById(input[i]).value);
+ var data = document.getElementById(input).elements;
+
+ for(i=0;i<data.length;i++) {
+ var frm_field = data[i];
+ post_data = post_data +'&' + frm_field.name + '=' + encodeURI(frm_field.value);
}
+
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
@@ -88,7 +96,7 @@ if (!http_request) {
return false;
}
- http_request.onreadystatechange = function() { getContents(http_request,output); };
+ http_request.onreadystatechange = function() { getContents(http_request); };
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", post_data.length);
|