getJson not running in IE 11 on external computers

匿名 (未验证) 提交于 2019-12-03 09:05:37

问题:

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);     }); 

回答1:

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]--> 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!