AMS
AMS

Reputation: 550

SCRIPT5009: 'JSON' is undefined in IE 10 The value of the property '$' is null or undefined, not a Function object

   <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Hello World</title>
        <link href="StyleSheet.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="Scripts/jquery-2.0.3.js">
            $(document).ready(function () {

                <%--$("#width").val() = $(window).width();
                $("#height").val() = $(window).height();--%>


            });
    </script>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#width").val($(window).width());
                $("#height").val($(window).height());
            });
        </script>
    </head>
<body>
    <form id="form1" runat="server">
<input id="width" type="hidden" runat="server" />
        <input id="height" type="hidden" runat="server" />
</form>
</body>
</html>

the above is my aspx code with jquery script which gives the window height and width.

this code perfectly fine on all the browsers when i run the web app from visual studio http://localhost/Mypage.aspx

but when i host it on iis and run with my machine name http://MyMachine/Mypage.aspx it gives JSON undefined and the Property "$" is null or undefined errors.( this is only in IE 10 (non-compatibility mode) , for chrome it works fine)

question 1) do we need to take care of any security constraints for IE 10?

question 2) why does it happen this way when i host it on iis and run it with machine name on my own machine?

question 3) am i missing any jquery refrence.

question 4) obvious one, any solution to this problem.

Upvotes: 6

Views: 4712

Answers (3)

user3639335
user3639335

Reputation: 58

use the Meta tag as suggested by many of the people.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

but I want to give an importatnt tip. the mata tag should be the first tag in the head tag. I have read it some where if it is not the first tag it would not have its effect.

Upvotes: 3

BraveNewMath
BraveNewMath

Reputation: 8323

as suggested by I4v, adding this to the header fixed the bug for me too:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Thanks guys

Upvotes: 0

xrodas
xrodas

Reputation: 486

Are you sure you have the Scripts folder with jquery in the server? I suggest you to debug with fiddler and see if jquery is loaded correctly or if there is an http error.

Upvotes: 0

Related Questions