Ajay
Ajay

Reputation: 6590

Javascript Runtime error: $ is undefined

I have added script in my Default.aspx page. I am getting following error. Error

Upvotes: 8

Views: 95836

Answers (5)

taylorsabell
taylorsabell

Reputation: 714

I had the same problem, but did have a correct reference to jQuery.

I solved it by referencing jQuery before any other scripts. In your case, it would look like this:

<script src= "scripts/jquery-ui.js" />
<script src= "scripts/JavaScript_scroll.js" />

Hope this helps anyone else with a similar issue.

Upvotes: 4

Mohsen Kamrani
Mohsen Kamrani

Reputation: 7457

(For others who may face the same problem as OP's)
I had the same problem, but the reason was that I was trying to load my jQuery script before loading the jQuery library itself. In other words, make sure that you first add this line:

<script src="Scripts/jquery-{version}.min.js"></script>

before adding

<script src="Scripts/JavaSript_scroll.js"></script>

Upvotes: 0

Abdul Khaliq
Abdul Khaliq

Reputation: 2285

I had the Same Problem as that $ is Unidentified, After a long struggle, I come to know that there is some thing HTML coder error in Master Page, So it worked fine when i include the Jquery files directly in Content pageenter image description here

Upvotes: 1

CodingIntrigue
CodingIntrigue

Reputation: 78525

You need to include jQuery: http://learn.jquery.com/about-jquery/how-jquery-works/

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Demo</title>
    **<script src="jquery.js"></script>**
</head>
<body>
  ...
</body>
</html>

Upvotes: 4

Marcelo Cantos
Marcelo Cantos

Reputation: 185842

$ is defined by jQuery, which you probably haven't referenced. A simple way to get it is to add one of the CDN urls to your template HTML:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

Upvotes: 29

Related Questions