Ze Carioca Silva
Ze Carioca Silva

Reputation: 443

Jquery and Asp.net MVC... How do I make it work in this case:

I created an Asp.net Mvc WebAplication with empty template;....

In the Index View of the Home Controller I have this:

<script type="text/javascript" src="~/Scripts/jquery-2.0.0.js"></script>
<script type="text/javascript" src="~/Scripts/Javascript1.js"></script>


<div class="letters">
<div class="letter" id="letter-a">
<h3><a href="#">A</a></h3>
</div>

I created a Javascript1.js file and I put this:

$(document).ready(function () {
    $('#letter-a a').click(function () {
           alert('Loaded!');
       });
});

But I am getting this error at runtime:

Unhandled exception at line 349, column 1 in http://localhost:55573/Scripts/jquery-2.0.0.js

 Microsoft JScript: 'JSON' is not defined

Here its the line where the code stops:

jQuery.extend({
// Unique for each copy of jQuery on the page
expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),

I already installed all the Json packages that I could find.... What should I do now?

Upvotes: 0

Views: 550

Answers (2)

Sadjad Khazaie
Sadjad Khazaie

Reputation: 2222

Put this in the head element of your cshtml or aspx:

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

X-UA-Compatible meta tag allows web authors to choose which version of Internet Explorer the page should be rendered.

Upvotes: 0

SLaks
SLaks

Reputation: 887225

Your version of jQuery does not support your version of IE.

IE <= 8 support was dropped in jQuery 2.0.

Upvotes: 4

Related Questions