1

I searched a lot for this but didn't found one matching exactly to my problem (Although I found certain matching ones but none helping). I'm working on a project to create web application of an ipad app in which I am accessing webservices for every task. For example, for login, I've to call an authenticate webservice which returns status text in a xml string. So, I've to achieve each of these tasks through synchronous ajax calls.

So, for example, say, I've a login page where I've to authenticate a user login. So, when a user enters his username and password and submits the form, the loading animation (a simple image with fixed position) shows up until the script gets response from the server. Everything is working fine one FF.

My problem starts in Chrome. It doesn't show me the loader. Rather, it freeze up the screen until the page gets some response from the server.

I know, I shouldn't use synchronous ajax but I'm bound to. I can't make changes in the prewritten script so I've to cope with it. So, I'm looking forward to someone who could help me showing up this loader in chrome until the page gets some response from the server.

And hey, just to mention, the page shows up the loader if I put an alert message just before the ajax call.

Sayed
  • 601
  • 6
  • 21
  • 8
    aaaaand ___this___ is why you shouldn't use synchronous AJAX – John Dvorak Oct 01 '13 at 10:45
  • For your own benefit, learn how to use asynchronous ajax calls. You'll find yourself applying the same theory to all sorts of things and your coding and apps **will** get better for it. – Reinstate Monica Cellio Oct 01 '13 at 10:47
  • as said, I'm bound to use synchronous ajax. I've been searching for hours for one single solution but didn't find any. Hard day for me :( – Sayed Oct 01 '13 at 10:48
  • @eddy well, there is no way around. If there was, there would be no drawbacks left to synchronous AJAX and everyone would be using it happily ever after. Frankly, I'm surprised it _doesn't_ freeze firefox. – John Dvorak Oct 01 '13 at 10:50
  • 1
    Incidentally, you can change the existing ajax calls' behaviour without changing the existing code ;) – Reinstate Monica Cellio Oct 01 '13 at 10:52
  • I was wondering if I could pass my post-ajax-respond function as parameter to the function containing the ajax call, so that I can have my manipulations once the script starts responding? – Sayed Oct 01 '13 at 10:53
  • Did you try using the ajaxStart event and starting the loader it self using jQuery. – Imesh Chandrasiri Oct 01 '13 at 10:54
  • @eddy once you do that, you can use asynchronous ajax as well. – John Dvorak Oct 01 '13 at 10:54
  • 1
    synchronous ajax = it will freeze. – John Dvorak Oct 01 '13 at 10:55
  • Okay. So, it seems like there is no work around. I'll have to recode that rough code again :( – Sayed Oct 01 '13 at 10:56
  • Try deferred.then() in jQuery. Display loader then initiate the ajax call using this. – clu3Less Oct 01 '13 at 11:30
  • please be a bit more specific on how to use it. I'm not an expert. Also, I'm bound to use synchronous ajax because the data being returned by ajax is being used at a lot of places to change the contents. – Sayed Oct 01 '13 at 11:36

0 Answers0