2013-02-18 45 views
0

我的jQuery/AJAXjQuery的/ AJAX装载的表上没有显示IE 9

function initializeDaily() { 
jQuery.post(
     'ajax-functions.php', 
     { 
      'action':'getdailyStatus' 
     }, 
     function(response){ 
      var html = response 
      $('#daily_result').append(html) //append to table #daily_result 

      var rowid = $('#daily_result tr:first-child').attr('id') 

      getDetails(rowid) 
     }) 
} 

这将工作在所有其他浏览,而不是在IE9装表。 getDetails(ROWID)将工作,所以我不相信有语法错误

,另一方面

,如果我这样做:

function initializeDaily() { 
jQuery.post(
     'ajax-functions.php', 
     { 
      'action':'getdailyStatus' 
     }, 
     function(response){ 
      var html = ' <table id="daily_result" cellspacing="0">'+"\n" 
      html += response 
      html += ' </table>'+"\n" 
      $('#data_scroll').html(html) //div that holds the table 

      var rowid = $('#daily_result tr:first-child').attr('id') 

      getDetails(rowid) 
     }) 
} 

表负载正常的,但我的$("#daily_result").on("click", "tr", function(event))不起作用。

有没有解决这个问题的方法? 这将是很大的帮助,如果任何人都可以告诉我是什么地方出了错=)

**编辑

确定...我设法得到它的工作。但是,我认为这不是最好的办法。

这是我做过什么:

jQuery.post(//its still post 
    'ajax-functions.php', 
    { 
     'action':'getdailyStatus' 
    }, 
    function(response){ 
     var html = response 

     $('#data_scroll').html(html) 

     var rowid = $('#daily_result tr:first-child').attr('id') 

     //moved my event handler here; after the loading of the table 
     $("#daily_result").on("mouseenter mouseleave", "tr", function(event){ 
      if(event.type == "mouseenter"){ 
       $(this).css("background","#999") 
       $(this).css("color","#FFF") 
      } 
      else { 
       $(this).removeAttr('style') 
      } 
     }) 
     getDetails(rowid) 
    }) 

有什么办法,我可以做得更好?

谢谢。

+0

你为什么不尝试jQuery.load – 2013-02-18 04:44:41

回答

0

尝试

$('#daily_result').load('ajax-functions.php', { 
      'action':'getdailyStatus' 
     }, function(){ 
      var rowid = $('#daily_result tr:first-child').attr('id') 
      getDetails(rowid) 
     }); 
+1

它仍然不只是为IE9 – Bananachipz 2013-02-18 05:01:31

+0

工作是有控制台 – 2013-02-18 05:45:17

+0

可惜没有=( – Bananachipz 2013-02-18 05:48:29