1

Any idea why the following code will not continually update in IE6 & 8 but works perfectly fine in Chrome and FF.

$(document).ready(function () {

        window.setInterval(function () {

            $('div').each(function (index, item) {

                var vm = $(item).text();
                var env = "some url (cant show)";

                $.ajax(env, {
                    URL: env,
                    type: "GET",
                    dataType: "html",
                    success: function (data) {                          
                        var style = $(data).filter('div');
                    $(item).replaceWith(style);

                    },
                    error: function () {
                        $(item).css('background', '#f00');
                    }
                });
            });
        }, 10000);
});

The divs will change once, then never again. Whereas, in Chrome and FF the divs change every 10 seconds as they are meant too.

Thank you for your help!

4

1 回答 1

0

尝试编写您的脚本(未测试)...

    $(document).ready(function () {

    window.setInterval(function () {

        $('div').each(function (index, item) {

            var vm = $(item).text();
            var env = "some url (cant show);

            $.ajax(env, {

                URL: env,

                type: "GET",

                cache:"false", //NOTICE FALSE!!

                dataType: "html",

                success: function (data) {


                    var style = $(data).filter('div');
                    $(item).replaceWith(style);

                },

                error: function () {



                    $(item).css('background', '#f00');

                }

            });
        });

    }, 10000);

});`
于 2012-07-11T17:02:14.290 回答