View Full Version : AJAX timing issues

09-10-2006, 07:06 AM

I have 3 divs being populated with content onload via Ajax:

<body onload="prod_options('add','hide'); categories_pulldown(); disp_cats();">

each of these functions uses the fairly standard xml httprequest call:

http.open('get', 'page_name.php', true);
http.onreadystatechange = handleResponse_options;

The problem is, I have to space out these calls and time it just right, or else this content doesn't load and I get errors in my Javascript console:

Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: https://mydomain.com/cms/store/inventory.js :: handleResponse_options :: line 61" data: no]
Source File: https://mydomain.com/cms/store/inventory.js
Line: 61

Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: https://mydomain.com/cms/store/inventory.js :: disp_cats :: line 104" data: no]

Wrapping these calls in a setTimeout works, but surely there must be a better way to do this? I've tried turning off async, but it seems like Firefox doesn't work with it off?

09-10-2006, 05:44 PM
Okay, setting the value of the async argument to "false" works just fine with Safari, but not with Firefox. So far, I haven't been able to reproduce this problem in Safari with teh async argument set accordingly. Of course, I'd very much like to get this working for Gecko too. If I figure this out, I'll post my solution.

09-10-2006, 06:46 PM
Looks like they are exploring this issue here:


09-10-2006, 10:55 PM
I think you just need to look into OO JavaScript.