Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2008, 02:22 PM   PM User | #1
nbfruit
New to the CF scene

 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
nbfruit is an unknown quantity at this point
AJAX progress graphic issue in Firefox

Hi,

I have implemented a progress graphic that works in IE but not in FF.

Basically, when the user clicks on a search button, my Javascript:

o hides the DIV with my search form
o reveals the DIV containing my progress graphic
o sets up the XMLHTTPRequest and sends it
o receives back the data
o updates my results DIV, which at this point is hidden
o hides my progress graphic DIV
o reveals my results DIV

All this works fine in IE, but in FF the hides/reveals don't work.

I know my code is OK in this regard, because if I stagger the script with an 'alert' after each hide/reveal, they all work fine.

Equally, if I remove the XMLHTTPRequest call, the functionality is also fine.

What appears to happen is that FF suspends all DOM updates if it is dealing with an XMLHTTPRequest in any part of the transaction.

Is that plausible?
nbfruit is offline   Reply With Quote
Old 09-29-2008, 02:45 PM   PM User | #2
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
Can we see your code?
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 09-29-2008, 02:46 PM   PM User | #3
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
Quote:
What appears to happen is that FF suspends all DOM updates if it is dealing with an XMLHTTPRequest in any part of the transaction.
well, if that were the case you'd have JAX, not AJAX :P


have you watched the transaction with firebug?
ohgod is offline   Reply With Quote
Old 09-29-2008, 03:15 PM   PM User | #4
nbfruit
New to the CF scene

 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
nbfruit is an unknown quantity at this point
Quote:
Originally Posted by ohgod View Post
well, if that were the case you'd have JAX, not AJAX :P


have you watched the transaction with firebug?
I have. Nothing doing. No errors.

Code is quite long so probably best to take a look at the actual site. All of the javascript can see via Firebug.

http://www.propertygetter.com

Do a search for properties in Northern Europe with Euro currency.

Map should disappear and display a 'Loading results' dialogue. It does in IE, not in FF.

Relevant code section is ajax_user.js, line 1234

Last edited by nbfruit; 09-29-2008 at 03:18 PM..
nbfruit is offline   Reply With Quote
Old 09-29-2008, 03:25 PM   PM User | #5
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
so, without looking at code i'm going to assume you're using onreadystatechange to define which step it's at. correct me if i'm wrong.

you're right, it showed the loading image in ie, and not firefox. but... when i hit search in firefox it loaded the results so freakin fast it wouldn't have needed it...
ohgod is offline   Reply With Quote
Old 09-29-2008, 04:58 PM   PM User | #6
nbfruit
New to the CF scene

 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
nbfruit is an unknown quantity at this point
Quote:
Originally Posted by ohgod View Post
so, without looking at code i'm going to assume you're using onreadystatechange to define which step it's at. correct me if i'm wrong.

you're right, it showed the loading image in ie, and not firefox. but... when i hit search in firefox it loaded the results so freakin fast it wouldn't have needed it...
Yes, I'm using onreadystatechange.

I've put a sleep() into my PHP to simulate a slow response from the webserver.
nbfruit is offline   Reply With Quote
Old 11-06-2008, 05:50 PM   PM User | #7
nbfruit
New to the CF scene

 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
nbfruit is an unknown quantity at this point
Resolved

Quote:
Originally Posted by ohgod View Post
so, without looking at code i'm going to assume you're using onreadystatechange to define which step it's at. correct me if i'm wrong.

you're right, it showed the loading image in ie, and not firefox. but... when i hit search in firefox it loaded the results so freakin fast it wouldn't have needed it...

Just an update to say that I finally resolved this issue.

readystatechange was the key.

Let me explain for those not too familiar with concept:

If you set the readystatechange optional Boolean parameter to true (asynchronous), your javascript will continue to execute while your browser is waiting for the response from the server.

If you set it to false (synchronous), your javascript will pause until the server responds.

Clearly, if you want to reveal a progress graphic while waiting for the server to respond, this parameter should be set to true, as your javascript will need to run to update your DOM.

I had not set the parameter, presuming the default was true. This didn't present a problem in IE, but in FF, my javascript was pausing.

Setting the parameter explicitly to true sorted the problem in both browsers.

Last edited by nbfruit; 11-06-2008 at 05:55 PM.. Reason: Resolved
nbfruit is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:07 PM.


Advertisement
Log in to turn off these ads.