diff options
Diffstat (limited to 'itjs/loader.js')
-rw-r--r-- | itjs/loader.js | 25 |
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 |