All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/plone-custom conga_ajax.js
Date: 12 Nov 2007 17:10:44 -0000	[thread overview]
Message-ID: <20071112171044.17990.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-11-12 17:10:43

Modified files:
	luci/plone-custom: conga_ajax.js 

Log message:
	support async POST requests

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/conga_ajax.js.diff?cvsroot=cluster&r1=1.3&r2=1.4

--- conga/luci/plone-custom/conga_ajax.js	2007/08/08 21:26:37	1.3
+++ conga/luci/plone-custom/conga_ajax.js	2007/11/12 17:10:43	1.4
@@ -9,7 +9,7 @@
 
 var xmlHttp_object = false;
 
-function initiate_async_get(url, callback_function) {
+function get_xmlhttp_obj() {
 	xmlHttp_object = false;
 
 	if (!xmlHttp_object && typeof XMLHttpRequest != 'undefined') {
@@ -27,14 +27,48 @@
 			}
 		}
 	}
+	return (xmlHttp_object);
+}
 
-	if (xmlHttp_object) {
-		xmlHttp_object.open("GET", url, true);
-		xmlHttp_object.onreadystatechange = callback_function;
-		xmlHttp_object.send(null);
-	} else {
+function initiate_async_get(url, callback_function) {
+	xmlHttp_object = get_xmlhttp_obj();
+
+	if (!xmlHttp_object) {
+		alert("Unable to communicate with the luci server.");
+		return (-1);
+	}
+
+	xmlHttp_object.open("GET", url, true);
+	xmlHttp_object.onreadystatechange = callback_function;
+	xmlHttp_object.send(null);
+}
+
+function initiate_async_post(form, url, callback) {
+	xmlHttp_object = get_xmlhttp_obj();
+	if (!xmlHttp_object) {
 		alert("Unable to communicate with the luci server.");
+		return (-1);
 	}
+
+	var form_data_str = '';
+	for (var i = 0 ; i < form.elements.length ; i++) {
+		switch (form.elements[i].type) {
+			case 'hidden':
+			case 'password':
+			case 'select-one':
+			case 'text':
+			case 'textarea':
+				form_data_str += form.elements[i].name + '=' +
+					escape(form.elements[i].value) + '&';
+		}
+	}
+
+	xmlHttp_object.onreadystatechange = callback;
+	xmlHttp_object.open('POST', url, true);
+	xmlHttp_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+	xmlHttp_object.setRequestHeader("Content-length", form_data_str.length);
+	xmlHttp_object.setRequestHeader("Connection", "close");
+	xmlHttp_object.send(form_data_str);
 }
 
 function get_ajax_msgs(obj, tag_name) {



                 reply	other threads:[~2007-11-12 17:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071112171044.17990.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.