summaryrefslogtreecommitdiff
path: root/itjs
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2006-11-20 20:40:32 +0000
committerThomas BrĂ¼derli2006-11-20 20:40:32 +0000
commitb097d8786f3e67d098ec274ac3ae182860943112 (patch)
treea13037e7434c5d949e2641a4244834cb4ee101b1 /itjs
parent63657f3cef518f9172181b0b828fa804f14008d2 (diff)
downloaditools-b097d8786f3e67d098ec274ac3ae182860943112.tar.gz
itools-b097d8786f3e67d098ec274ac3ae182860943112.tar.bz2
itools-b097d8786f3e67d098ec274ac3ae182860943112.zip
Added method for sending HTTP POST requests
Diffstat (limited to 'itjs')
-rw-r--r--itjs/loader.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/itjs/loader.js b/itjs/loader.js
index 19f5f9c..8a22e95 100644
--- a/itjs/loader.js
+++ b/itjs/loader.js
@@ -24,6 +24,8 @@ clear: function()
this.entry = new Array();
this.start = this.end = 0;
this.attr = { num: 0, loadtime: 0 };
+ this.method = "GET";
+ this.post_data = null;
if (this.handler.clear)
this.handler.clear();
@@ -87,7 +89,7 @@ load: function(baseurl, pos, num, query_volatile, retry)
try
{
- this.loader.open("GET", baseurl + "&pos=" + pos + "&num=" + num + (query_volatile ? query_volatile : ""));
+ this.loader.open(this.method, baseurl + "&pos=" + pos + "&num=" + num + (query_volatile ? query_volatile : ""));
var me = this;
this.loader.onreadystatechange = function() { me.readyStateChanged(); }
var workingxmlhttp = this.loader.onreadystatechange;
@@ -101,7 +103,7 @@ load: function(baseurl, pos, num, query_volatile, retry)
{
this.starttime = new Date().getTime();
this.retry = retry;
- this.loader.send(null);
+ this.loader.send(this.post_data);
}
else
{
@@ -124,6 +126,25 @@ load: function(baseurl, pos, num, query_volatile, retry)
this.handler.render(this);
},
+post: function(baseurl, data)
+{
+ this.clear();
+ this.method = "POST";
+ this.baseurl = baseurl;
+ this.start = this.end = 10;
+ this.post_data = "";
+
+ if (typeof data == 'object')
+ {
+ for (var k in data)
+ this.post_data += (this.post_data ? "&" : "") + k + "=" + escape(data[k]);
+ }
+ else
+ this.post_data = data;
+
+ this.load(baseurl, 0, 1, "");
+},
+
readyStateChanged: function()
{
var loader = this.loader; // Avoid race conditions