Firefox AJAX Bug - Plus Workaround


Today we stumbled across a fairly significant firefox bug with popup windows and making XHR requests. Here is the scenario:

We have a calendar selection popup window for our users to select a date (typical of any reservation website). User clicks calendar icon, calendar select popup appears, user selects date, popup window closes & fills text field with date.

Today we wanted to add an AJAX call triggered just as the popup window closes. This call would request filtered data for another field based on the date selected. The AJAX call (via DWR) was working fine when we didn’t use the calendar popup, but when using the popup we would get “No data received from server” from DWR.

Luckily we found a reference to the firefox bug on the dwr mailing list.

Basically, Firefox incorrectly tries to make the XHR call from the popup window (even though the javascript explicitly says to call the XHR from the opener). The workaround is to call the dwr function from inside a window.setTimeout(‘myAjaxCall()’,0). This will allow the window to close successfully in Firefox.

Here’s the code example from the example website:

Without seeing your code its hard to say, but I bet that from your popup you are invoking a dwr call on the popup’s window.opener. (i.e. in your popup you have something like window.opener.makeDWRCall()). The problem is when you do that, the XMLHttpRequest is “owned” by the popup window even though the call resides on your main window.

If you take a look at the Firefox bug listed above you will see a workaround to the issue:

function closePickupWindow(id) {
opener.pickupId.value = id;
if (opener.pickupFunctionPointer != null) {


// This is to work around the following bug in firecox
function launchLookup() {
window.setTimeout(‘pickupFunctionPointer()’, 0);

Some of this code is extraneous, but the basic idea is that from your popup you call a function on window.opener that uses setTimeout to issue the DWR call. Note that the timeout can be instantaneous because all you are really trying to do is change the caller of the DWR function to window.opener instead of your popup.

Hope this helps.
John Kleinschmidt