這段JQuery為什麼IE8會報錯?但卻有正常執行完成?

edited 十月 2013 in Javascript
節錄一段
success:function(a)
        {
            if(a.status)
            {
                $('#vs_main_load').hide();
                $('#vs_main_main').html('');
                var data=a.data;
                var year;
                var month;
                var list;
                var line;
                var ele;
                var red;
                for(year in data)
                {
                    for(month in data[year])
                    {
                        $('#vs_main_main').append($('<div></div>').attr('class','vs_date_title').html(year+'.'+month));
                        list=data[year][month];
                        for(line in list)
                        {
                            red=100;
                            if(list[line]['f_members']==0 && list[line]['t_members']==0)
                            {
                                red+=50;
                            }
                            else
                            {
                                var t=(list[line]['f_members']/(list[line]['f_members']+list[line]['t_members']))*100;
                                if(t!=0)
                                {
                                    red+=(100-t);
                                }
                            }
//問題出在ele這一段,IE報不能調用attr(),實際上還是有調用完成,我嘗試不用連串法,但結果一樣...
                            ele=$('<div></div>').attr('class','vs_box').append($('<div></div>').attr('class','vs_box_title').append($('<div vsid="'+list[line]['vs_id']+'"></div>').attr('class','vs_box_title_text').html(list[line]['title']))).append($('<div></div>').attr('class','vs_box_img').append($('<div></div>').attr('class','fmembers').html(list[line]['f_members'])).append($('<div></div>').attr('class','vs_box_red_line').css({'margin-left':red+'px'})).append($('<div></div>').attr('class','tmembers').html(list[line]['t_members'])));
                            $('#vs_main_main').append(ele);
                        }
                    }
                }
            }
        },

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=5655

評論

  • edited 一月 2011
    補充一下原始的json資料
    {"status":true,"data":{"2011":{"1":[{"vs_id":"1","title":"\u6e2c\u8a66\u4e00\u500b\u65b0\u8a71\u984c","t_members":"0","f_members":"0"},{"vs_id":"2","title":"aaaaaaa","t_members":"0","f_members":"0"},{"vs_id":"3","title":"aaaa","t_members":"0","f_members":"0"},{"vs_id":"4","title":"aa","t_members":"0","f_members":"0"}]}}}
    
  • edited 一月 2011
    嗯..json的斜線又被吃掉了 XD
    問題已經不存在...奇怪我今天再用ie開同一頁面..啥都沒動,竟然就正常了...
    真不知道是卡到什麼陰...
Sign In or Register to comment.