Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


Synchronizing Multiple AJAX Calls In Window.onload() Event

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload == 'function') {
window.onload = function() {
} else {
window.onload = func;


My problem is that some of these myFunction#s include AJAX calls but
the calls depend on each other in such a way that myFunction2 will not
work unless myFunction1 has completed. So what is the "nicest" way to
make sure of this? I've considered putting a hidden element in the
HTML and then changing it at the end of each function call and have
the onchange event trigger the next function call. But this seems very
hacky and overcomplicated - surely there must be a simpler and better

View 5 Replies (Posted: May 18th, 2007)

Sponsored Links:

Related Forum Messages For JavaScript category:
Adding Function Calls During Onload Page Event?
I have the following javascript function:

[ function addNewWindowEvent(evType, fn)
if (window.addEventListener)


Posted: 11-10-2010, 11:20 PM

View 1 Replies!   View Related
Have An Html Page That When It Loads Theres An OnLoad Event Called Which Calls A Function?
i have an html page that when it loads theres an onLoad event called which calls a what i want to do is be able to click a link that refreshes the page but at the time on the refresh it skips the onLoad event. is this possible?

Posted: January 24th, 2006

View 5 Replies!   View Related
Closing Popup Window Via X Button And Onload Window Event?
I have a popup window. There are 2 ways you can close it: pressing a close button within the popup window or by pressing the x button in the upper right hand corner of the window. They have the exact same effect. If I could disable the x I would, but that is unnecessary and not happening anytime soon in your favorite browser. In essence, I am doing some post-processing when the window is closed (session clean-up actually) and am not spawning endless new popup windows to annoy my users. Trust me, the customer asked for this behavior.

So I could do window.onunload or I can do the body onunload and either way will give me the results I wish. However, there is a third scenario which complicates matters. Within the popup window, there can be a form submission which alters the contents of that popup window. If this is the case, either window.onunload or body unload will be invoked, depending upon which I have setup on my page. This is not what I want. I want the post-processing to happen upon the popup window visually disappearing from sight (x or close button), but not to post-process when a form submission has taken place leaving the popup still visually on this screen.

EDIT: My attempt at a solution which does not trigger window.onunload

function searchFieldTitles()
var searchOptionValue;
var radioObj = document.getElementsByName("searchOption");


Posted: Jun 16 11 at 20:39

View 1 Replies!   View Related
Detecting The Onload Event Of A Window Opened With
window.popup =$(this).attr('href'), 'Ad', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');
$(window.popup).onload = function()
alert("Popup has loaded a page");

This doesn't work in any browser I've tried it with (IE, Firefox, Chrome). How can I detect when a page is loaded in the window (like an iframe onload)?

Posted: Jun 13 10 at 2:31

View 3 Replies!   View Related
The Window.onload Event Is Not Firing In IE8?
I stripped down this javascript to be as simple as possible, and it's still not working in IE8.

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload !== 'function') {
window.onload = func;


In Firefox, Opera, Safari, and Chrome, I get "Before onload", "After onload", then the page appears, then "Onload". In IE8, that last step doesn't happen. window.onload simply isn't firing.

Posted: Mar 2 at 13:19

View 1 Replies!   View Related
Access A Remote Window's Onload Event?
If I use a window opener to open a new window, is there a way to detect that the new window is finished loading before carrying out some other directive in the opener window? Can I access the remote window's onload event from the opener window? I need to know that the website has loaded before moving to the next page. something like:

remoteWindow.onload = goToPage(url);

Posted: 12-07-2009, 10:08 PM

View 2 Replies!   View Related
Window.onload Event Correct Usage?
I have this loop code to reduce the DOM calls in my javascript, and reuse them.

aarr = [];
for (var z=1; z<=10; z++) {
c = z-1;
aarr[c] = document.getElementById("a"+z);

I have been shown that if the code is ran before the DOM is complete, then the array is null. Moving the script after the last html code will work. So now I want to put this code inside the window.onload event so to not have to move the script code to the bottom of the page. But it apparently does not work because it appears that the array loop is executed before the DOM is completed.


Posted: Sep 6 11 at 22:35

View 4 Replies!   View Related
Appcelerator Titanium: Use The OnLoad Event Of An Window?
mainWin.addEventListener('load', function(e) {
if(mainWin.pageLoad) {


Posted: Apr 5 11 at 9:58

View 4 Replies!   View Related
Silverlight 3 Onload Event Binding Multiple Instances
I have two silverlight instances embedded in a page like follows (content simplfied to relevant details only):-


As you can see both objects point at the same xap but will have different content in the initParams. Note, however, that the onload param points to the same function name. This particular part of this question is invariant. Elsewhere in javascript at the global level I have:-

function silverlight_onload(sender, eventargs)
//Magic pixie dust here

The goal is to take the sender and determine which of the object elements is the source of the event. The straight-forward (but for the sake of this question unacceptable) answer would be to use two different functions. I'm look for something that does not require a new function be added to the global namespace per SL object. Bonus, kudos goes to anyone who can tell me why SL couldn't get a little more assistance from the host browser and handle the onload parameter more like other element events like onlick. For example ask the browser to eval("function() {" + onload + "}" and attach the return function to the onload event.

Posted: Sep 8 09 at 15:16

View 2 Replies!   View Related
Pass A PHP Variable To A Window.onload Event Function?
How do I pass a PHP variable into a window.onload event function? I have a URL that I need to pass to the JavaScript file that has this function in it. The JavaScript file itself is being linked from the PHP file that will pass the variable and I've seen many examples of how this is done via embedded JavaScript, but none where someone is linking to an external JavaScript file. I suppose this is probably a trivial matter to most of you, but I've never done this before and could use some guidance!

Posted: Dec 21, 2009

View 16 Replies!   View Related
Multiple Onload Event - Utilize Two Separate Onloads Events
I am new to Javascript and am trying to add some functionality to a website but have come across a problem when trying to utilise two seperate Javascript onloads events. I have a text scroller to display the latest news and I also have a javascript lightbox gallery. Both of these events work perfectly on their own but when I try to include both on one page only one of the events is executed. My code is displayed below:

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="js/"></script>

Posted: 08-10-2009, 10:25 AM

View 4 Replies!   View Related
Ajax :: Multiple Calls Without Disturbing Others?
I have created Dynamic Tabs by using Jquery. In each tab, I have sent a ajax call and get some information and do some functions. My problem is, If i create a First tab, the ajax call called and got informations and done some dunctions. Same as if i create second tab, that also work properly.

But If i create Second tab, when First tab ajax call or functions running, it stops the operation and second tab operations are started. i want to create second tab dynamically, when the First tab functions Running(without stopping this)..

Posted: Aug 16 11 at 8:00

View 3 Replies!   View Related
Back Button Causes IFrame To Delay Window.onLoad Event?
I serve ads through an iFrame. The ad network's servers are much slower than mine, so I asyncronously load the iFrame on the window.onload event.

// (using Prototype library)
Event.observe(window, 'load', function() {
$('ad').writeAttribute('src', '/ad.html');
// other initialization here

A problem occurs when you enter the site via the browser's back button. Unexpectedly, the ad iFrame attempts to load immediately (before the load listener above sets the 'src' attribute), delaying the load event for a few seconds. During these few seconds, the site is unusable because I do a bunch of initialization in window.onload.

As far as I know, this only happens in Firefox. How do I prevent this blocking load?

Posted: Dec 28 10 at 23:24

View 4 Replies!   View Related
JQuery :: Prevent Multiple Calls Of A Custom Event Handler When Using The Observer Pattern?
I am using jQuery to implement the observer pattern. I am triggering a custom event on $('body *') because it is not know what elements will respond to the event. That is, I want to enable my fellow developers to add code to respond to the event without me having to know about it. The problem I am encountering is that any child elements of an element bound to the custom event execute the handler. Is there a way to make sure that these child elements do not execute the handler? Keep in mind that I can't trigger on the element itself, because that element is unknown. I would like to avoid having the target elements add a class if possible.

Here is some example code:



Posted: Jun 29 11 at 23:25

View 1 Replies!   View Related
JQuery :: Multiple Ajax Calls On One Page?
Basically, what I am trying to do is call several ajax requests using jQuery on the same page, i know that all browsers are capable of requesting multiple requests. However in Chrome and Safari my website works fine, but IE, Firefox and Opera all only call the first request then dont call, the second two. I dont know why though?

All of the code for the site is here: [URL]

Posted: Jan 12th, 2011

View 5 Replies!   View Related
Jquery :: Callback For Multiple Ajax Calls?
My lack of javascript knowledge is getting me in trouble again. I think this should be a fairly easy problem to fix but I cant figure it out.

Situation: I want to make three ajax calls in a click event. Each ajax call does a distinct operation and returns back data that is needed for a final callback. The calls themselves are not dependent on one another, they can all go at the same time, however I would like to have a final callback when all three are complete.


Posted: Dec 6 10 at 17:02

View 9 Replies!   View Related
AJAX :: Multiple Calls For A Table Initialized More Than Once?
I have a fragment on the page that gets loaded via AJAX. That page contains a table that will be powered and populated by Datatables with server-side processing. Everytime I load the fragment that contains a new table, I tell Datatables to boot the table from scratch, using bDestroy : true.


Posted: Jul 20 11 at 13:52

View 1 Replies!   View Related
Ajax :: Jsf 2.0 - JSF F:event PreRenderView Is Triggered By F:ajax Calls And Partial Renders - Something Else?
So we have an f:event:

<f:event type="preRenderView" listener="#{dashboardBacking.loadProjectListFromDB}"/>

Which is triggered as desired on initial page load (render). However this preRenderView event is also triggered by an ajax partial page render, which re-renders an h:panelgroup with the id projectListing, as below.

<h:commandButton action="#{mrBean.addProject}" value="Create Project"
title="Start a new project">
<f:ajax render="projectListing" />

I only want the dashboardBacking.loadProjectListFromDB to be called for the initial page render, but not when there is an ajax partial render. Is there a more appropriate event or method I could be using?

Posted: May 13 10 at 22:52

View 5 Replies!   View Related
AJAX :: .net - Different Between ASP.NET PageLoad() And Window.onload?
I'm working with ASP.NET AJAX and want to understand the difference between these two snippets:

function pageLoad(sender, eventArgs) { }


window.onload = function() { }

Do they act the same? Or is one called before the other? Or will one be called automatically and the another not?


View 1 Replies!   View Related
AJAX :: Call Multiple Functions On Onload?
how to load multiple functions on window.onload and these functions could be in a seperate ajax file.

<script type="text/javascript">


func1 and func2 are in a seprate ajax file. In this case only func2 works and func1 is not works.

Posted: 01-28-2010, 12:05 PM

View 2 Replies!   View Related
Ajax :: Multiple Calls Same Page Stops Working IE?
I have several ajax calls that originates from the same page its updating. It works perfectly in firefox but in IE it works for about 18 requests and then just stops until the page is refreshed. I thought it was a cashe issue but I have added a variable for that. I think it may have something to do with binding but I am not sure how to sort that. This is one of my functions.


Posted: August 16th, 2011, 12:31 AM

View 3 Replies!   View Related
Screen Locked In Between Multiple Synchronous Ajax Calls?
I'm trying to make a little loop that in each itteration executes a little php script to send mail with the mail() function. the php script returns either succes or failure. Now its my intention to append that msg to a div, after every execution.

type: "POST",
data: dataString2,
url: "sendmail.php",
async: false,
success: function(result)

the show status(result) is nothing more then a .append(result) the zenMails(y) calls this function again to send the next mail. It does work though but it only updates the div after the entire loop is done, i 'ld think it ld do so after every execution since i call the showstatus when the synchronous call is done and only after that i call the next iteration. Is there anyway to work aroud this ? (making the call assync doesnt work , because the port for sending the mail would still be in use)

Posted: February 22nd, 2011, 02:39 AM

View 1 Replies!   View Related
JQuery :: Multiple Ajax Loading Animations On Calls?
On a page I have different element which I bound yo different Ajax calls.For example one is requesting x.php another one down the same page requests y.php.

What I like to do is place an individual loading image for each.ajaxStart and ajaxStop won't do it since they are fired everytime, no matter which one called.So how I can do it for individual calls?

Posted: Mar 10 10 at 18:25

View 1 Replies!   View Related
AJAX :: Prevent Multiple Web Service Calls Via JQuery
I'm starting to integrate some jQuery calls in my Classic ASP pages but want to prevent the user from clicking buttons multiple times and sending multiple server queries.

Posted: Mar 27 at 19:12

View 2 Replies!   View Related
Copyright 2005-08, All rights reserved