3

I have function that looks like this:

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

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.

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.

barbajoe
  • 547
  • 5
  • 15
  • 2
    IE11 is probably caching your page. I had the same issue with a dynamic form... Try this and see if it fixes it on YOUR client: http://stackoverflow.com/questions/18083239/what-happened-to-always-refresh-from-server-in-ie11-developer-tools – StaticVoid Jun 27 '14 at 19:47
  • 2
    also you can change your one line with `.data()` : `var url = $(item).data("url");` – Jai Jun 27 '14 at 19:52
  • 1
    IE must be caching your code. http://stackoverflow.com/questions/1061525/jquerys-load-not-working-in-ie-but-fine-in-firefox-chrome-and-safari – Manoj Mohandas Jun 27 '14 at 19:54
  • the HTML was getting cached, I'm now keeping that page from caching and all is right in the world again. thanks for the pointers! – barbajoe Jun 27 '14 at 20:04

1 Answers1

4

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

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

barbajoe
  • 547
  • 5
  • 15