的getJSON没有外部计算机上运行的IE浏览器11 [英] getJson not running in IE 11 on external computers

查看:121
本文介绍了的getJSON没有外部计算机上运行的IE浏览器11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建基于MVC模型的一个简单的WebAPI分2次服。我创建了一个简单的前端的index.html网页,其中有一个按钮来调用的getJSON 通话,传递一个相对URI。如果成功,应该显示一个警告框。 在本地开发计算机,一切正常的IE和Chrome浏览器。但是,当我尝试从另一台计算机访问网络上,它停在IE浏览器的工作,但仍然在Chrome浏览器工作正常。我所有的IE都是11版本以下是的getJSON code段。我试图从其他岗位的许多建议,如使用阿贾克斯,而不是用缓存:假跨域:真正的,并使用JSONP而不是

在IE浏览器不工作,我尝试手动输入完整的地址,在电话的getJSON和它的实际工作。所以我猜出于某种原因, .getJson 呼叫没有执行。任何帮助是极大的AP preciated。

  $。的getJSON(URI +/+文件路径)
    .done(功能(数据){
        警报(测试);
    })
    .fail(功能(jqXHR,textStatus,ERR){
        $('#产品)文本(错误:+ ERR)。
    });
 

解决方案

发布万一有人回答别人跑了进去。在我的情况下,IE浏览器在加载一个版本的jQuery,显然原因JSON未定义的错误。这是我做过什么来解决这个问题:

 <! -  [如果其中IE 9] GT;
    &所述;脚本的src =的http://$c$c.jquery.com/jquery-1.10.2.js>&所述; /脚本>
百分比抑制率ENDIF]  -  GT!;
&所述;! -  [如果GTE IE 9]≥&所述;! - >
    &所述;脚本的src =的http://$c$c.jquery.com/jquery-2.0.3.js>&所述; /脚本>
<! - <![ENDIF]  - >
 

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

解决方案

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

这篇关于的getJSON没有外部计算机上运行的IE浏览器11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆