Reputation: 46479
I came across this complication when loading content through ajax. I usually use window.load to check if everything is loaded up and only than I display content, there is loading animation before.
this is done to hide bits from user that are styled via javascript and without hiding them page looks ugly for a split second. It stopped working after I started loading content via ajax, and it than turned out that you can't use window.load with it.
I tried looking for replacement method, but had no luck. Has anyone had luck with this and found similar solution that works with ajax?
Upvotes: 0
Views: 490
Reputation: 26
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
//your code for loading done goes here
});
Should work as expected :)
Upvotes: 0
Reputation:
Use the success:
callback on your $.ajax()
call to do the styling and display your page once the content is loaded.
Upvotes: 2