Solved

How Do You Start JavaScript On MVC Page Load?

Posted on 2014-07-28
6
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 110

Expert Comment

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

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:danielolorenz
ID: 40224481
Not yet
0
 
LVL 110

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 110

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 74
make control visible based off other control value 7 42
How to pass values to HTML-5 attribute dynamically? 24 62
Make icons act like add/minus for qtys 6 40
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…
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…

739 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