Solved

How Do You Start JavaScript On MVC Page Load?

Posted on 2014-07-28
6
248 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 109

Expert Comment

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

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:danielolorenz
ID: 40224481
Not yet
0
 
LVL 109

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 109

Expert Comment

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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript Form Change 5 31
Hide cell in a table 2 27
Question about traversing a tree using jQuery 7 33
Need a simple RegEx to search for two words 27 41
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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)
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

808 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