473,670 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2532
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,nu m)
{
document.getEle mentById('put_h ere').innerHTML =
document.getEle mentById('put_h ere').innerHTML +
' <br>' + t + ' [# of connections: ' + parseInt(xmlreq s.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_ma in_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.XMLHttp Request)
{
// Mozilla, etc.
xmlhttp=new XMLHttpRequest( );
xmlhttp.onready statechange = xmlhttpChange;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send(nu ll);
}
// IE
else if (window.ActiveX Object)
{
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
if(! xmlhttp)
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
if (xmlhttp)
{
xmlhttp.onready statechange = xmlhttpChange;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send();
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xm lreq);
}

function xmlreqPOST(url, data)
{
var xmlhttp=false;
if (window.XMLHttp Request)
{
// Mozilla etc.
xmlhttp=new XMLHttpRequest( );
xmlhttp.onready statechange=xml httpChange;
xmlhttp.open("P OST",url,true) ;
xmlhttp.setRequ estHeader("Cont ent-Type",
"applicatio n/x-www-form-urlencoded");
xmlhttp.send(da ta);
}
else if (window.ActiveX Object)
{
// IE
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
if (xmlhttp)
{
xmlhttp.onready statechange=xml httpChange;
xmlhttp.open("P OST",url,true) ;
xmlhttp.setRequ estHeader("Cont ent-Type",
"applicatio n/x-www-form-urlencoded");
xmlhttp.send(da ta);
}
}

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

for (var i=0; i < xmlreqs.length; i++)
{
if (xmlreqs[i].xmlhttp.readyS tate == 4)
{
if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status ==
304)
{
// 200 OK
update_log(xmlr eqs[i].xmlhttp.respon seText,-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.goo glegroups.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,nu m)
{
document.getEle mentById('put_h ere').innerHTML =
document.getEle mentById('put_h ere').innerHTML +
' <br>' + t + ' [# of connections: ' + parseInt(xmlreq s.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_ma in_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.XMLHttp Request)
{
// Mozilla, etc.
xmlhttp=new XMLHttpRequest( );
xmlhttp.onready statechange = xmlhttpChange;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send(nu ll);
}
// IE
else if (window.ActiveX Object)
{
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
if(! xmlhttp)
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
if (xmlhttp)
{
xmlhttp.onready statechange = xmlhttpChange;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send();
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xm lreq);
}

function xmlreqPOST(url, data)
{
var xmlhttp=false;
if (window.XMLHttp Request)
{
// Mozilla etc.
xmlhttp=new XMLHttpRequest( );
xmlhttp.onready statechange=xml httpChange;
xmlhttp.open("P OST",url,true) ;
xmlhttp.setRequ estHeader("Cont ent-Type",
"applicatio n/x-www-form-urlencoded");
xmlhttp.send(da ta);
}
else if (window.ActiveX Object)
{
// IE
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
if (xmlhttp)
{
xmlhttp.onready statechange=xml httpChange;
xmlhttp.open("P OST",url,true) ;
xmlhttp.setRequ estHeader("Cont ent-Type",
"applicatio n/x-www-form-urlencoded");
xmlhttp.send(da ta);
}
}

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

for (var i=0; i < xmlreqs.length; i++)
{
if (xmlreqs[i].xmlhttp.readyS tate == 4)
{
if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status ==
304)
{
// 200 OK
update_log(xmlr eqs[i].xmlhttp.respon seText,-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.goo glegroups.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.goo glegroups.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
4942
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., http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=Tidy7IDbDHA.2108%40cpmsftngxa06.phx.gbl) that indicate that ASP will queue up requests when they come in with the same "session".
1
1285
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 changed compared to that currently displayed - if it hasn't changed, it does not update anything. I'm having a problem on ONE single computer in that changed data is being sent but the script doesn't see it. I found that if I cleared the browser...
4
5218
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, RAM, DISK? Do we lose everything if the machine is just rebooted or we can save all messages on disk to send them later where we're on line? Just D.
1
1638
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 a textbox. Thanks Tiger
1
1546
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 exactly the same in regards to software, yet only one machine repeatedly shows queuing on the performance counter ASP.NET Requests Queued. No other machines show any queuing at all. The queuing occurs on the machine in question only after it is put...
7
2410
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 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.
8
3288
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 from each .xml file in a subdirectory on the webserver. Ex <A Href=" " </a as text.
4
2981
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: //------------------------------------------------------------------------------------- for (i=0; i<data.length; i++) { httpRequest = false; httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function(index) {
35
9347
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 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.