• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ajax inefficiency?

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic