Start jQuery After Page Has Fully Loaded

No comments
Assume that, you are creating an application using jQuery with any server side language for example PHP and you want to run an AJAX code when your page is fully loaded and then fire your code. In this case using $(document).ready() is not going to fulfill your expectations and you will wish to find a better solution that can help you out from this. This tutorial is going to show a method to you to run your code when your page is fully loaded.

If you want to run your code when the page is fully loaded then you can use following code:

<script type="text/javascript">
jQuery(window).on("load", function () {
alert('hi akhilesh');
});
</script>
The window load event execute when the page is fully loaded means, all the images, js files, css files and other objects.

However, if you want to run fire your jQuery code when the HTML is loaded and the DOM is ready then use document ready event. See example below:

<script type="text/javascript">
$(document).ready(function() {
alert('hello akhilesh');
});
</script>


No comments :

Post a Comment