473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multiple XMLHTTPREQUESTS and Queuing...

Hello helpful computer people!

I can't seem to get more than one request to fire simultaneously... and
I have read there should be at least 2 possible (in IE) and more in
Firefox.

I made a demo based on this article/code "Handling Multiple
XMLHTTPRequest Objects" at
http://www.drakware.com/articles/multijax.php, which does make mutliple
requests, but never two seem to happen at the same time.

See my demo at:

http://s161149005.onlinehome.us/DEMO...ltiple_03a.htm

Hit a bunch of buttons and see how they start "sending", but always
"answer back" in order. If there were 2 calls happening
simultaneously, the shorter calls (Button C, which does only "5
Calculations/Loops") would "jump" over the longer calls when it
answered back.

1. Am I missing something? (Or am I right, there is only one request
happening at a time)
2. Can I do anything to get more than one XMLHTTPRequest going at a
time?
3. Could this be a server issue? (Maybe ASP/IIS has a limit on the
backend?)

Thanks for any help. I just started doing the Ajax stuff, and thought
I saw a world of opportunity, but if I can't get more than one thread
at a time I don't know how much use it will be to me...

Thanks for any comments/help,
Blue Apricot

Apr 16 '06 #1
7 2507
If it helps, here is some code. There are 3 files, a normal HTML page
that has the buttons, an external Javascript file (see below), and a
simple ASP file that does some dummy calculations to "waste time" and
then sends a Response.Write back to the page that started things...

Here is the .js:

function update_log(t,num)
{
document.getElementById('put_here').innerHTML =
document.getElementById('put_here').innerHTML +
' <br>' + t + ' [# of connections: ' + parseInt(xmlreqs.length+num)
+']'
}

function sendData(l,x)
{
update_log('<b><i>Button "' + l + '" clicked, Sending
Request</i></b>',1)
var queryString = 'AJXloops=' + x + '&AJXaction=' + l
var url="respond_main_03a.asp";
xmlreqPOST(url,queryString)
}

//
------------------------------------------------------------------------------------------------
// Based on Code from http://www.drakware.com/articles/multijax.php
//
------------------------------------------------------------------------------------------------

var xmlreqs = new Array();

function CXMLReq(type, xmlhttp)
{
this.type = type;
this.xmlhttp = xmlhttp;
}

function xmlreqGET(url)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla, etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
// IE
else if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
if(! xmlhttp)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}

function xmlreqPOST(url,data)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
else if (window.ActiveXObject)
{
// IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
}

var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}
function xmlhttpChange()
{
if (typeof(window['xmlreqs']) == "undefined") return;

for (var i=0; i < xmlreqs.length; i++)
{
if (xmlreqs[i].xmlhttp.readyState == 4)
{
if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status ==
304)
{
// 200 OK
update_log(xmlreqs[i].xmlhttp.responseText,-1)
xmlreqs.splice(i,1); i--;
}
else
{
// error
xmlreqs.splice(i,1); i--;
alert("A problem occurred!");
}
}
}
}

Apr 16 '06 #2
Do you jhave debugging enabled on your ASP application? If so it will only
process one request at a time. So your second request remains in the request
queue at server until the first request is finished.

Anthony.

<bl************@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
If it helps, here is some code. There are 3 files, a normal HTML page
that has the buttons, an external Javascript file (see below), and a
simple ASP file that does some dummy calculations to "waste time" and
then sends a Response.Write back to the page that started things...

Here is the .js:

function update_log(t,num)
{
document.getElementById('put_here').innerHTML =
document.getElementById('put_here').innerHTML +
' <br>' + t + ' [# of connections: ' + parseInt(xmlreqs.length+num)
+']'
}

function sendData(l,x)
{
update_log('<b><i>Button "' + l + '" clicked, Sending
Request</i></b>',1)
var queryString = 'AJXloops=' + x + '&AJXaction=' + l
var url="respond_main_03a.asp";
xmlreqPOST(url,queryString)
}

//
-------------------------------------------------------------------------- ---------------------- // Based on Code from http://www.drakware.com/articles/multijax.php
//
-------------------------------------------------------------------------- ----------------------
var xmlreqs = new Array();

function CXMLReq(type, xmlhttp)
{
this.type = type;
this.xmlhttp = xmlhttp;
}

function xmlreqGET(url)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla, etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
// IE
else if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
if(! xmlhttp)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}

function xmlreqPOST(url,data)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
else if (window.ActiveXObject)
{
// IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
}

var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}
function xmlhttpChange()
{
if (typeof(window['xmlreqs']) == "undefined") return;

for (var i=0; i < xmlreqs.length; i++)
{
if (xmlreqs[i].xmlhttp.readyState == 4)
{
if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status ==
304)
{
// 200 OK
update_log(xmlreqs[i].xmlhttp.responseText,-1)
xmlreqs.splice(i,1); i--;
}
else
{
// error
xmlreqs.splice(i,1); i--;
alert("A problem occurred!");
}
}
}
}

Apr 16 '06 #3
>Do you jhave debugging enabled on your ASP application?

Hmmm, how can I find out?

I didn't change any settings or put in code that I think would enable
debugging, but I am not sure how to do it, so could it have been done
by default? Or on a standard IIS install?

Blue Apricot

Apr 16 '06 #4

<bl************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Do you jhave debugging enabled on your ASP application?


Hmmm, how can I find out?

I didn't change any settings or put in code that I think would enable
debugging, but I am not sure how to do it, so could it have been done
by default? Or on a standard IIS install?

Blue Apricot


No you'd have to turn it on deliberately.

Open properties of the application folder or web site, select home directory
tab and open the application configuration dialog. On the App Debugging
page if any of the debugging flags are checked then debugging is enabled for
the application.

When debugging is enabled there is only a single worker thread to process
requests. Hence multiple requests will get queued.

But of course I'm being really dumb ("nothing new there!" I hear a few
snigger)...

Requests to ASP pages by the same session will have to be serialised. The
Session state object is a Single Threaded object it can't be shared by two
requests being processed simultaneously. You might try the App Options tab
of the Application Configuration dialog and turn off 'Enable session state'
that will probably help I've not tried it myself. Of course if you need
session state then you're stuck but I think this will help prove your AJAX
stuff.

Anthony.
Apr 16 '06 #5
Thanks Anthony,
I turned off 'Enable session state' and my Ajax stuff is working now.
Thanks for walking me through that.

One final quick question (sorry)...

What will be the impact of turning off session state?

Can I still use session variables, for instance?
Will it effect stuff in my Global.asa file?

Thanks so much,
Blue Apricot

Apr 16 '06 #6

<bl************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Thanks Anthony,
I turned off 'Enable session state' and my Ajax stuff is working now.
Thanks for walking me through that.

One final quick question (sorry)...

What will be the impact of turning off session state?

Can I still use session variables, for instance?
Nope session variables will not be available
Will it effect stuff in my Global.asa file?
Application events and the application object should continue as normal.

I've not tried it but I suspect the session events won't run at all
(otherwise they'd have to run for every request and that would be
undesirable).


Thanks so much,
Blue Apricot


Apr 16 '06 #7
Thank you very much for your answers, Anthony. You have been a great
help.

I really appreciate it. :)

Blue Apricot

Apr 16 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
1
by: Martin | last post by:
I have a situation where I'm using XmlHttpRequests to update some data in a table every few seconds. The script that executes when the data comes into the browser checks to see if the data has...
4
by: Just D. | last post by:
Did anybody use this Message Queuing and knew all details about it? What's the physical limit of this Message Queuing system, number of messages, mbytes, message size? Where it stores messages,...
1
by: tiger | last post by:
Hi, I have a question on MS Message queuing. I would like to check a message queuing to see if there is a message in the queue. That is if the queue is empty, I would like to send a note to...
1
by: Dave Pink | last post by:
I support a web server farm of about 80 machines, of which 35 are in Production at any given time. Machines are running Windows 2000 Advanced Server with IIS 5. All 80 machines are configured...
7
by: blueapricot416 | last post by:
Hello helpful computer people! I can't seem to get more than one request to fire simultaneously... and I have read there should be at least 2 possible (in IE) and more in Firefox. I made a...
8
by: jhoff | last post by:
So, I'm in a pickle... Lets say I have a page: http://www.gen2host.com/discgolf/index.html and on this page, there are a list of links. These links will be generated by 5 pieces of data pulled...
4
by: jeff.maildump | last post by:
Hi, I've got multiple xmlhttprequests which are in a loop. So this is the loop I have so far, with the closure given to me in a previous post: ...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.