getJson not running in IE 11 on external computers
Asked Answered
K

1

2

I'm building a simple WebAPI 2 service based on the MVC model. I've created a simple front-end index.html page which has a button to invoke the getJSON call, passing a relative URI. If this succeeds it should display an alert box. On the local dev machine, everything works for both IE and Chrome. However, when I try accessing from another computer on the network, it stops working in IE, but still works ok in Chrome. All of my IE are version 11. Below is the getJson code snippet. I have tried many suggestions from other posts such as using .ajax instead with cache:false, crossDomain:true, and using jsonp instead.

In the IE that doesn't work, I tried manually type in the full address as that in the getJson call and it actually works. Therefore I'm guessing for some reason the .getJson call is not executing. Any help is greatly appreciated.

$.getJSON(uri + '/' + filepath)
    .done(function (data) {
        alert('test');
    })
    .fail(function (jqXHR, textStatus, err) {
        $('#product').text('Error: ' + err);
    });
Kikelia answered 12/3, 2014 at 22:16 Comment(2)
Press F12 to open IE dev tools and look at console or network tab to find out what going on.Diversified
Thanks! I checked the network tab before and didn't see anything. Forgot about the console, I checked it and found the error. It was due to IE running on older mode thus loading incompatible jquery version. It is fixed now.Kikelia
K
2

Posting the answer just in case somebody else runs into it. In my case IE was loading a version of jquery that apparently causes "JSON undefined" error. Here is what I did to solve it:

<!--[if lt IE 9]>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
    <script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<!--<![endif]-->
Kikelia answered 13/3, 2014 at 3:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.