Reputation: 681
I know this might sound similar to a few questions on SO already, but they somehow don't convince me with any best practice.
Now I know, its a pretty straightforward advice while using AJAX, never (ever) go for Synchronized XHR. But what if that XHR is part of some validation criteria which if succeeds has to open some popups. The moment the asynch XHR is invoked, the User Event has ended. The Popups that were intended to open in the callback will never happen if the browser is doing its job well.
What should be nice workaround that might settle for best practice in such scenario.
One clean solution that I've read is to open the popups right away and change their behavior in the callback. Now this may work ofcourse with extra state that needs to retained till we enter the callback. Is there a better solution out there than this? Or should the saner minds stick to Synchronized XHR if its not causing too much trouble?
Upvotes: 2
Views: 653
Reputation: 44376
One clean solution that I've read is to open the popups right away and change their behavior in the callback.
That was going to be my answer when I saw the title of your question.
Now this may work ofcourse with extra state that needs to retained till we enter the callback.
Declare the callback as a closure within the function that creates the pop-up. It will inherit all the state and the browser won't lock up.
Upvotes: 1