Reputation: 969
I am using asp.net MVC 5 and trying to get jQuery alert message when a form completely loads all its content. I have the following code that executes successfully and displays alert that time when a form has nothing displayed and totally blank, thanks
<script>
alert("Registered Successfully");
</script>
Upvotes: 0
Views: 2540
Reputation: 1391
Slight variation that is even shorter:
<script>
$(function() {
alert("Registered Successfully");
});
</script>
Upvotes: 0
Reputation: 68902
You can do one of these:
- Put your script at the end of the page.
- Write your code in $(function() { });
or $( document ).ready(function() { }
- Write your code in $(window).load()
to wait for all content including images.
- Without jQuery:
window.onload = function WindowLoad(event) {
alert("Page is loaded");
}
Upvotes: 2
Reputation: 3034
Wrap it in document.ready:
<script>
$("document").ready(function(){
alert("Registered Successfully");
});
</script>
Or, use the shorthand:
<script>
jQuery(function($) {
alert("Registered Successfully");
});
</script>
Upvotes: 2