I am having problems updating elements that are not ready after an ajax request.
If I run the myFunction() function when the page loads like this:
$(function() { myFunction(); }
I do not have any problems. But if I then use something like
$.ajax({ url: this.href, dataType: "script", complete: function(xhr, status) { myFunction(); } });
which returns $(".myElement").replaceWith("htmlHere") . Elements are simply not ready when the full event fires. If I set the delay there, it works fine again.
Is there another event that fires differently than is "completed" when the DOM is ready?
Update:
Here is the actual code:
$(function() { $("a.remote").live("click", function(e) { $.ajax({ url: this.href, dataType: "script", success: function(xhr, status) { myFunction(); } }); e.preventDefault(); return false; }); myFunction(); }); function myFunction() {
Is absent); was just a typo on my part.
Ive tried to use success now instead of complete, and it does not seem to make any difference.
Danny source share