/    Sign up×
Community /Pin to ProfileBookmark

multiple xmlhttprequests

I’m trying to set up a page which read the table and then makes a single XMLhttprequest post to a CGI program for every entry. I’ve been able to do everything except submit multiple posts. what’s making this difficult is that I need to serialize requests because each request can take up to three or four seconds to execute. The test page is at [url=http://harvee.org/files/correct.html] http://harvee.org/files/correct.html[/url] and the JavaScript pages at [URL=http://harvee.org/files/camram.js]http://harvee.org/files/camram.js[/URL]

the actual code which is causing the problems is:

[code]var table_list = null;
var table_index = 0;

function processtab(){
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
alert(“got XMLHttpRequest”);
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject(“Microsoft.XMLHTTP”);
}
build_table();
//alert(“built table”);
//alert(“pre open”);
self.xmlHttpReq.open(‘POST’, “/cgi/test”, true);
//alert(“post open”);
self.xmlHttpReq.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);

//alert(“pre orsc”);
self.xmlHttpReq.onreadystatechange = function() {
//alert(“pre state test”);

if (self.xmlHttpReq.readyState == 4) {

if (table_index < table_list.length){

var el = table_list[table_index];
var working = el;

while (working.tagName != “TR”){
working = working.parentNode;
}

working.style.visibility = ‘hidden’;
working.style.display = ‘none’;
alert(“in loop”);
table_index += 1;
self.xmlHttpReq.send(send_query_string());
}
}
} ;
alert(“pre-send”);
self.xmlHttpReq.send(send_query_string());
return false;
}
[/code]

I haven’t found anything on the net describing how to handle this problem. if I’m missing something, please let me know.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @esjatharvee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...