I run a $.get() call as soon as JS is executed, this is before the $(document).ready() is triggered. How can I use the result of the $.get as soon as $(document).ready() was triggered? I don’t want to send the $.get() after $(document).ready() was triggered.
Solution: As Jonathan Julian mentioned I came across this solution:
$.get('my_script.php', function(data) {
$(document).ready(function() {
// I can use data here as soon as document is available!
// No flickering of the updated div! :)
});
});
In your
successhandler, do what you need to do in a$(document).ready()function. It will either run right away, or wait until the document is ready.