473,395 Members | 1,474 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.

Nesting AJAX

Is it possible to do this? Does AJAX allow one call to be made within
another?? So far I'm having problems. Below I've tried to simplify my
code into its basic elements - the problem I'm getting is that that
ResponseHandler1 is getting called fine from an intial call to
NestedAjaxCalls but ResponseHandler2 (the nested call) isn't. I've
tested out this very code to make sure!

function NestedAjaxCalls() {
var ajax_connection = createRequest();
ajax_connection.open('get', 'request1.php');
ajax_connection.onreadystatechange = function() {
ResponseHandler1(ajax_connection);
}
ajax_connection.send(null);
}

function ResponseHandler1(ajax_connection) {
var ajax_connection2 = createRequest();
ajax_connection2.open('get', 'request2.php');
ajax_connection2.onreadystatechange = function() {
ResponseHandler2(ajax_connection);
}
}

function ResponseHandler2(ajax_connection) {
// Does not get called
echo('Success! Nested AJAX call was made successfully.');
}

// create an AJAX Request
function createRequest() {
var ajaxRequest;

try
{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1)
{
try
{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
ajaxRequest = new XMLHttpRequest();
}
}

return ajaxRequest;
}

Is it something simple I'm doing wrong like the scope of my connection
variables or is this a limitation with AJAX - if so could anyone
suggest an alternative method of doing the same thing? Any replies
gratefully received...

Cheers,
Steve

May 22 '07 #1
1 2804
st************@gmail.com wrote:
Is it possible to do this? Does AJAX allow one call to be made within
another?? So far I'm having problems. Below I've tried to simplify my
code into its basic elements - the problem I'm getting is that that
ResponseHandler1 is getting called fine from an intial call to
NestedAjaxCalls but ResponseHandler2 (the nested call) isn't. I've
tested out this very code to make sure!
<snip code>
>
Is it something simple I'm doing wrong like the scope of my connection
variables or is this a limitation with AJAX - if so could anyone
suggest an alternative method of doing the same thing? Any replies
gratefully received...
I would suggest you take a look at Matt Kruse's http://www.ajaxtoolbox.com/

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 22 '07 #2

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

Similar topics

3
by: Michael Hertz | last post by:
I have hundreds of samples of XML documents on my harddisc. But all of them lack the one or another feature of XML. Some XML documents have no attributes some others are rather flat (nesting...
0
by: Wolfgang Schwanke | last post by:
Dear usenet, I'm having the following small problem. I've been ask to add some Quicktime panoramas to a website. The author of the panoramas has made two versions of each: One in MOV format,...
8
by: CoolPint | last post by:
I read in books that nested class cannot access private members of nesting class and vice versa unless they are made friends. Somehow, my compiler is letting my nested class member functions access...
8
by: Hardrock | last post by:
I encountered some difficulty in implementing dynamic loop nesting. I.e. the number of nesting in a for(...) loop is determined at run time. For example void f(int n) { For(i=0; i<=K; i++)...
5
by: jack | last post by:
Hi I wanna know if nesting of tags inside similar tags is possible in XML. To be more clear, is <person> <son> <person>
4
by: kl.vanw | last post by:
I would like to count the nesting level in template classes. How can I make the following work? #include <assert.h> template <class T> class A { public: A() { // what goes here?
6
by: stephen.cunliffe | last post by:
Hi, I'm looking for opinion/facts/arguments on the correct nesting of UL, OL, & LI elements. For example, this is what I want (unordered list): * Item 1 * Item 2 * Item 3
17
by: henry | last post by:
Folks Here's a skeleton, generic HTML page, call it "index.php". You'll see a bit of php code in the middle: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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.