473,395 Members | 1,335 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,395 software developers and data experts.

AJAX concurent queries

Hi

How can I make several asynchronous XMLHttpRequest queries?

The one thought I have is to have few XMLHttpRequestObjects and send
queries using them alternately. But what if i don't know how many
queries I need to send? (btw: I know only which handler functions must
be used to handle the queries' response).

Does any one know where to look for answer to this problem or maybe
someone have some code snippets i could learn from.

--
Thank you
Ralph
Nov 19 '06 #1
6 1545
Ralph wrote:
How can I make several asynchronous XMLHttpRequest queries?
All halfway-decent ajax libraries should do this easily.
For example:
http://www.ajaxtoolbox.com/request/examples.php

(See 'Simultaneous Requests)
The one thought I have is to have few XMLHttpRequestObjects and send
queries using them alternately.
Create one each time you make a request, or keep a pool of them around to
re-use once they are used.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 19 '06 #2
You could put all requests in a Container object, storing the actual
request objects in some array, and upon receipt of 4/200 kill the entry
with array.splice(). The Container would need to expose only .Request as
a public method, I think.

Have you had a look into www.twilightuniverse.com?

Ralph schreef:
Hi

How can I make several asynchronous XMLHttpRequest queries?

The one thought I have is to have few XMLHttpRequestObjects and send
queries using them alternately. But what if i don't know how many
queries I need to send? (btw: I know only which handler functions must
be used to handle the queries' response).

Does any one know where to look for answer to this problem or maybe
someone have some code snippets i could learn from.
--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html
Nov 19 '06 #3
Matt Kruse wrote:

Thank you very much for response I went over the code and I have one
question:

In one of your examples you are making simultaneous queries using the
function like this:

AjaxRequest.get(
{
'url':'sleep.pl'
,'onSuccess':function(req){ target.value=req.responseText; }
}
);

In this snippet you are defining function what to with responseText. Is
it possible to declare handling function somewhere else (lets say within
different file and call it like this:

AjaxRequest.get(
{
'url':'sleep.pl'
,'onSuccess':my_handler(req)
}
);

That would allowed me to use my existing functions to handle responses.

--
Big thanks!
Ralph
Nov 19 '06 #4
Ralph wrote:
Is it possible to declare handling function somewhere else (lets say
within different file and call it like this:
AjaxRequest.get(
{
'url':'sleep.pl'
,'onSuccess':my_handler(req)
Of course, but it would be
'onSuccess':my_handler

Writing it like you have done would call my_handler at the time of the
AjaxRequest.get() function call, and assign its result to the onSuccess
attribute.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 19 '06 #5
Most of the javascript tutorials are pretty horrible when it comes to
concurrent queries. The solution is to set up an object. It's one of
the first things I did when I started tinkering with my site, and I
actually wrote an article documenting it just to help test the site out.
You can snag the code (use freely) at http://www.hunlock.com

Once set up you can define new handlers on demand (and destroy ones no
longer in use), you can even have an array of them.

Good luck, and hope this is what you're looking for.

---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Nov 20 '06 #6
pcx99 wrote:
Most of the javascript tutorials are pretty horrible when it comes to
concurrent queries. The solution is to set up an object. It's one of
the first things I did when I started tinkering with my site, and I
actually wrote an article documenting it just to help test the site out.
You can snag the code (use freely) at http://www.hunlock.com

Once set up you can define new handlers on demand (and destroy ones no
longer in use), you can even have an array of them.

Good luck, and hope this is what you're looking for.

---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Thank you very much.

--

Ralph
Nov 21 '06 #7

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

Similar topics

17
by: psimakov | last post by:
I wrote a small piece about AJAX without XML. http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=AJAXWithoutXML Is anybody else doing it? Please share your thoughts...
6
by: petermichaux | last post by:
Hi, Reading the Yahoo! UI AJAX library, there is a unique workaround for an apparent IE 6 memory leak with binding a function to onreadystatechange. Instead of binding a function to...
3
by: caston | last post by:
Well, everybody can now agree with the fact that the Ajax hype is over. Still multiple Ajax Frameworks are flourishing, aren't they? So, last night I questioned myself with the following: "When...
2
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the...
6
by: mattdaddym | last post by:
Hi all, I'm looking for a way to show my users the progress of their sql queries. I've implemented Microsoft Ajax in order to show a progress bar, but I would love to be able to show: number...
5
by: pbd22 | last post by:
Hi. I am having a hard time figuring this one out... I have a sign in page. in my sign in logic, the successful login uses forms authentication and assigns an HttpCookie for the site-wide...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
1
by: bdbeames | last post by:
I have a page with google maps up and running. When a user clicks on a location from the map I would like to populate a drop down with data from the database related to that location. I have it up...
3
by: Kenneth Baltrinic | last post by:
Our team needs an AJAX based query builder that ideally plays well with ..Net, something along the lines of the Microsoft Outlook Filter Dialog. We found one item on CodeProject.com...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.