I have multiple jquery ajax calls that are somewhat interdependent. Both are fired on page load at different times (with getData being called before showData and showData is dependent on getData being called first).
On some clients, the showData runs first before getData.
-
How do I recreate this error as we don’t see that happening everywhere. It appears that this depends on the load on the server but we are unable to confirm that.
-
To fix it, I understand I can use Jquery’s
queueanddequeue. However, in certian scenarios, I need to run this outside of the queueing infrastructure. For example, mygetDatalooks like this:function getData() { $.ajax(//options) } function showData() { $.ajax(//options) }
Sometimes, I need both of them to be executed (with getData being called first), but in certain scenarios, they are independent of each other with getData being called without ever calling showData.
If I queue them up, can I still call them independently?
I think you should use the Deferred object types available in jQuery 1.5+ rather than a queue: