Jquery 这在IE中不起作用。。。有人能告诉我为什么吗?

Jquery 这在IE中不起作用。。。有人能告诉我为什么吗?,jquery,Jquery,我有一小段代码,只需从我们的一个网站上获取新闻稿: $(document).ready(function(){ items = []; curr_item = 0; $.getJSON('/press-release/feed/', function(data){ items = data; render(0); next = setInterval(next_rele

我有一小段代码,只需从我们的一个网站上获取新闻稿:

    $(document).ready(function(){
        items = [];
        curr_item = 0;
        $.getJSON('/press-release/feed/', function(data){
            items = data;
            render(0);
            next = setInterval(next_release, 5000);
    });

    function next_release() {
        //make sure we can't fall off the end of the array
        if(curr_item == items.length-1)
            curr_item = 0;
        else
            curr_item++;

        render(curr_item);
    }

    function render( index ) {
        item = items[index].fields;
        $('#ticker-text a').fadeOut('slow', function(){
            $(this).attr('href', '/press-release/' + item.slug).text(item.title);
            $(this).fadeIn('slow');
        });
     }

    });
以下是HTML:

    <div id="news-ticker">
        <span id="ticker-text"><a href=""></a></span>
         <ul>
            <li><a href=""></a></li>
         </ul>
    </div>


出于某种原因,这不会在IE中呈现JSON字符串中的新闻稿文本,但在safari、chrome、firefox和opera中效果良好。。。有人能帮忙吗?

“IE在JS中执行正确性方面确实做得很好。它会在
{'aaa'、'bbb'、}
上失败,因为后面有逗号,
FF
和Chrome会忽略错误。有时发现问题会让人恼火,但一旦发现问题,你的代码就更好了。”


--谢谢David,这就是问题所在。

您是否遇到javascript错误?或者只是没有返回?我得到的错误是:网页错误详细信息消息:对象不支持此操作行:28字符:8代码:0 URI:这是“item=items[index].fields”;谢谢,我应该在我的问题中也注意到这一点。啊,我明白了!多谢各位,我想IE会强迫你们先申报你们的VAR?最佳实践?(尽管如此,我认为IE和最佳实践永远不应该在同一个上下文中)IE在JS中执行正确性方面确实做得很好。由于后面的逗号,它将在{'aaa','bbb',}上失败,其中FF和Chrome将忽略错误。有时发现问题会让人恼火,但一旦你做了,你的代码就更好了。JeffC-既然问题解决了,你应该用有效的方法回答问题,然后接受它。这样它就不会显示为未回答!