BRHETT
BRHETT

Reputation: 55

jQuery isn't working in IE

I'm trying to make it where users can load their content in real time. The jQuery works perfect in Chrome and Firefox, but isn't working in any version IE. Any suggestions?

$(function () {
    var refreshContent = 0;
    $('#userDiv') .mouseover (function () {
        refreshContent = setInterval(function () {
            $.get("../pages/content/myContent.php", function(results) {
                $('#myContent') .html (results);
            });
            clearInterval(refreshContent);
        }, 1000);
    });
    $('#userDiv') .mouseout (function () {
        clearInterval(refreshContent);
    });
});

Upvotes: 0

Views: 161

Answers (1)

Ringo
Ringo

Reputation: 5483

Why are you using setinterval() at all? It doesn't make sense to me. Get rid of the mouseout event and the refreshContent variable. Use setTimeout() instead, it should work fine.

My guess is that it doesn't work in IE because the clearInterval() is being called before the $.get() even fires.

Upvotes: 1

Related Questions