Solved

How Do You Start JavaScript On MVC Page Load?

Posted on 2014-07-28
6
249 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

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
I'm a Human captcha checkbox 13 39
How to make google charts responsive 4 46
How to calculate height of a text using jquery 3 41
Jquery driving me nuts... 14 27
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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 …
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…

735 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