• 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

Change cursor during Ajax

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been struggling with how to change the cursor when AJAX is executing and change back to normal after it's completed. I'm using async:false in jquery. Thnks
 
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
Why have you turned aysnch off? That is not recommended for almost all situations.

And you can use the event callbacks to change the CSS when the request starts and completes.
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not using CSS for this particular page. I turned off async because it produced unpredictable result. There's a sequence of code that sometimes works and sometimes produces error when async is true. Is there no other solution? I must use css? thanks
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason you're getting unpredictable results is because you're probably not using callbacks properly. Instead of disabling the option, use it correctly.

And why are you not using CSS? It's almost like saying, hey I want to make a web page, but I'm not using HTML.
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have sequential AJAX calls where the each call depends on the previous ones (except for the first call). without asych:false, everything breaks down. I'm thinking about something more like document.body.style.cursor, but it didn't work out. Currenly it's only a page with a background image and a simple button (that invokes series of ajax calls). That's why I don't use css (yet).
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you already tried performing the next Ajax call in the callback function of the previous one?
 
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
Stephan is speaking wisely. You should be triggering Ajax calls that need to be sequential in the callbacks. And CSS should be used for all styling.
 
author
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using a synchronous call basically locks up the page and it will not update. So changing the cursor and having the screen update is in a race condition with the Ajax call locking the browser.

synchronous calls are bad and there are always solutions to make the asynchronous, you just have to code them differently.

Eric
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This doesn't work. Am I missing something here?
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea about jQuery, but as per the documentation: http://api.jquery.com/jQuery.ajax/ it should be something more like this:



And what the other guys are suggesting is that you invoke the next AJAX request in that success function.
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even for AJAX that's not sequential, if I set aysnc:true, it won't work. I'm filling two dropdowns. I call ajax to retrieve the datas from server to then be filled into the dropdowns. the ajax for both calls are exactly the same. In this case, the order of both calls doesn;t really matter since they don't need data from each other. So I must set aysync false; I've tried with true, doesn't work. the dropdowns don't get filled. And I've tried the method above, still not working.
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should show us your real code so we can help you further.
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator






 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic