I have a problem, mainly with IE.
I need to be able to handle n requests one by one. But if I just call my function below in IE loop, then it does some strange things (for example, it loads only so many calls). If I use the warning window, this proves that the function receives all the calls, and surprisingly IT WORKS!
I assume IE needs more time than other browsers, and the warning window does just that.
Here is my code:
var Ajax = function(all) { this.xhr = new XMLHTTPREQUEST(); // Function returns xhr object/ activeX this.uri = function(queries) { // Takes an object and formats query string var qs = "", i = 0, len = size(queries); for (value in queries) { qs += value + "=" + queries[value]; if (++i <= len) { qs += "&"; } } return qs; }; xhr.onreadystatechange = function() { // called when content is ready if (this.readyState === 4) { if (this.status === 200) { all.success(this.responseText, all.params); } this.abort(); } }; this.post = function() { // POST xhr.open("POST", all.where, true); xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xhr.send(uri(all.queries)); }; this.get = function() { // GET xhr.open("GET", all.where + "?" + uri(all.queries), true); xhr.send(); }; if (this instanceof Ajax) { return this.Ajax; } else { return new Ajax(all); } };
This function works fine for a single request, but how can I make it work when called so many times in a loop?
source share