Solved

How Do You Start JavaScript On MVC Page Load?

Posted on 2014-07-28
6
245 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now