aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Ajax inefficiency? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax inefficiency?" Watch "Ajax inefficiency?" New topic
Author

Ajax inefficiency?

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok, I have an ajax function that is retrieving data, and setting
a grid (<table> based on that data returned.

so in my onreadystatechanged function I have it to where
if the statechanged is not equal to 4 then I disable the body.

But I've noticed that if the internet is bogged down, it sometimes
does not fill the grid correctly. Should I just not disable the body
and hope they don't click on stuff randomly?

Thanks,

Justin Fox


You down with OOP? Yeah you know me!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

You can never guarantee that a request on the net will complete, Ajax or otherwise.

Perhaps you need to set a timeout so that if the request doesn't complete within a certain period your page can do the most appropriate recovery.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
well the thing is, I dont think the request is failing,
because I'm alerting my responseText and everything is good.

I was just wondering if my enabling the body when the statechanged == 4
and disabling when the statechanged != 4 could possibly bring about some problems with the rendering of the page if everything doesn't happens exactly like is supposed to. I guess.

I don't really understand that much about data travel between Gets and post, so I cant really make a valid statement about it lol.

Thanks a lot,

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Actually, that doesn't seem like a particularly good way to do it. What is it that you are actually trying to accomplish?

Are you just trying to disable the page while the request is processing?
[ June 13, 2008: Message edited by: Bear Bibeault ]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Yeah.

what im doing is, I get a string from the server that when eval is an Array in javascript.

example: 'new Array(1,2,3,16,17)'

and in my table, I have divs with id's like so:
frame1,frame2,...,frame24

so i just do a loop
and set the:


but while the ajax funtion getting the array text is 'requesting' (i guess) i set the document.body.dissabled = 'true'
and document.body.dissabled = 'false' when it is done

Justin Fox
[ June 13, 2008: Message edited by: Justin Fox ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Not the friendliest UI...

But, you could either simply disable the body just before making the Ajax request, and re-enable it when the request completes. Of make the request synchronous.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
its just something to keep the user from thinking that the button is broke or something, because there is no message while requesting e.g ("getting reserved days for '06/12/2008'").

but yea I'll probably just do like you said and disable right before i call the send function...

and re-enable the body afterwards..

Thanks for the input...

Justin Fox
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax inefficiency?