Solved

How Do You Start JavaScript On MVC Page Load?

Posted on 2014-07-28
6
246 Views
Last Modified: 2014-07-29
I need to start JavaScript on MVC page load.  

Here is my code:
<script type="text/javascript">
    $(document).ready(function () {
        //called when the document is ready
        alert('Page Load!')
    });
</script>

It is not working.

Thanks,

Dan
0
Comment
Question by:danielolorenz
  • 4
  • 2
6 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40224282
Have you loaded the jQuery library?
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40224294
Please see http://iconoun.com/demo/temp_danielolorenz.php

<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">


<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
    alert('PAGE LOAD');
});
</script>


<title>HTML5 Page in UTF-8 Encoding</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>

Open in new window

0
 

Author Comment

by:danielolorenz
ID: 40224480
Not yes
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:danielolorenz
ID: 40224481
Not yet
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40224643
Uhh, OK.  Maybe it would be best to do that :-)

You can copy the code I posted and install it on your server.  When you run it you will see that it works as expected.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40226621
Thanks for the points and thanks for using E-E, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS Plugin Chaining 2 32
Polygon I google maps 1 16
Randomize in Owl Carousel v1.3.2 6 20
How to generate a JSON response in coldfusion 4 22
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now