...

View Full Version : AJAX timing issues



besson3c
09-10-2006, 06:06 AM
Hello,

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;
http.send(null);


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?

besson3c
09-10-2006, 04: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.

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

http://www.ajaxfreaks.com/forums/index.php?showtopic=44&pid=174&st=0&#entry174

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

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum