$(item).load()脚本中断(仅在IE11中),适用于开发人员工具 [英] $(item).load() script breaking (only in IE11), works in developer tools

查看:76
本文介绍了$(item).load()脚本中断(仅在IE11中),适用于开发人员工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的功能看起来像这样:

I have function that looks like this:

function foo(item) {
    var url = $(item).attr("data-url");
    if (url && url.length > 0) {
        $(item).load(url);
    }
}

此功能由下拉菜单触发.change( )事件。 load()调用MVC4 Partial View,它返回html。这一切在Chrome和Firefox中运行良好和花花公子,但它在IE11中不起作用(我没有在旧版本的IE中测试,因为我不支持这种情况下的那些)。但是,只要我在IE中打开开发人员工具,一切都很完美;除了命中F12之外,我不需要做任何工作。

This function is triggered by a drop downs .change() event. The load() calls out to an MVC4 Partial View, which returns the html. This all works fine and dandy in Chrome and Firefox, but it doesn't work in IE11 (I haven't tested in older versions of IE since I don't support those in this circumstance). However, as soon as I open the Developer Tools in IE, everything works perfectly; I don't have to do anything besides hit F12 for it to work.

我的js文件中没有任何控制台代码,服务器正在推回有效的HTML,我找不到任何其他问题需要研究。

I do not have any "console" code in my js files, the server is pushing back valid HTML, and I can't find any other issues to look into.

我讨厌提出这样一个开放式的问题,但是你可以给我一些关于寻找什么的建议吗?我在网上找到的唯一东西是拔出任何控制台代码(我首先没有这个代码)。

I hate to make such an open ended question, but can you give me some advice on what to look for? The only things I could find online were to pull out any "console" code (which I didn't have in the first place).

非常感谢任何建议/指导。

Any suggestions/guidance is greatly appreciated.

推荐答案

问题是IE正在缓存我的调用结果。 IE的开发者工具(据我所知)在启用时会自动从页面中删除缓存,这就是为什么当我尝试在IE中调试时我的页面工作的原因。为了解决这个问题,我只需放置代码

The issue was that IE was caching the results of my calls. IE's Developer Tools (from what I understand) automatically removes caching from a page when it's enabled, which is why my page worked when I tried to debug it in IE. To solve the problem I simply placed the code

$.ajaxSetup({ cache: false });

在我的 $(文件).ready 部分。这使得页面不会缓存任何ajax结果并解决了我的问题。

at the begining of my $(document).ready section. That keeps the page from caching any ajax results and solved my issue.

这篇关于$(item).load()脚本中断(仅在IE11中),适用于开发人员工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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