2013-03-30 28 views
0

在此代碼中每一個事情是工作,但在瀏覽器傾斜後導入新的內容jQuery函數不包含室內用工作。對()函數

HTML代碼應用jQuery函數:

<div class="id2" > </div> 

     <div style="clear: both"></div> <br/> 

鏈接

    <div class="read"> 
       <table cellpadding="0" cellspacing="0" id="table" width="100%"> 



      </table> 
      </div> 

jQuery代碼:此代碼 有2個功能,第一個功能插入到數據庫,並導入新的內容 第二本功能離子其將從數據庫和隱藏TR從表中刪除 刪除的用戶不能從表中刪除的問題時,該內容從第一功能的進口,, jQuery函數不工作

/* DELET和隱藏**/

$(document).on("click", "#backup", function(){  // when click 'the link' this will import new content and update databace and i use .on() function for it 
    var s = { 
     "id": "backup_tables" 
     }; 
    $.ajax({   // here will do some thing in databacse 
     url : "function.php", 
     type : "POST", 
     data :s, 
     success : function (data){ 
     $(".id2").stop().stop().html(data).fadeIn(1000).delay(3000).fadeOut(500); // here the massges for user will set in the class "id2" 
     }, 
    }); 

     var s = { 
     "id": "backup_readlast" 
     }; 

    $.ajax({ // hrer will add new content 
     url : "function.php", 
     type : "POST", 
     data :s, 
     success : function (data){ 
     $(".read table tr:last").after(data);  // here will set the new content in the end of table and it's working , 
     $("#table tr:last").hide().fadeIn(800);  // but The problem that the import content is not applies jquery code 
     }, 
     beforeSend : function(){ 

     $(".id2").html("<img scr =\"../images/loading.gif\" alt=\"\" />"); 

     } 
}); 
return false; 
}); 
     /*** delet and hide ****/ 
$(".backupdelete").click(function(){ // here this function must be work after import new content ,, but desn't work 
      var name = $(this).attr("title"); 
      var s = { 
     "id": "backupdelete", 
     "id2" : name 
     }; 
    $.ajax({ 
     url : "function.php", 
     type : "POST", 
     data :s, 
     success : function (data){ 
     $(".id2").stop().stop().html(data).fadeIn(500).delay(2000).fadeOut(500); // here the massges for user will set in the class "id2" 
     }, 
     beforeSend : function(){ 
     $(".id2").html("<img scr =\"../images/loading.gif\" alt=\"\" />"); 
     } 
    }); 
$(this).closest('tr').fadeOut(500); 
return false; 
}); 
+0

什麼jQuery的版本是您使用?你在控制檯中收到任何錯誤? –

回答

0

所以,在每一個情況下都使用上():

/*** delet and hide ****/ 
    $('body').on('click',".backupdelete",function() { // here this function must be work after import new content ,, but desn't work 
     var name = $(this).attr("title"); 
     var s = { 
      "id": "backupdelete", 
       "id2": name 
     }; 
     $.ajax({ 
      url: "function.php", 
      type: "POST", 
      data: s, 
      success: function (data) { 
       $(".id2").stop().stop().html(data).fadeIn(500).delay(2000).fadeOut(500); // here the massges for user will set in the class "id2" 
      }, 
      beforeSend: function() { 
       $(".id2").html("<img scr =\"../images/loading.gif\" alt=\"\" />"); 
      } 
     }); 
     $(this).closest('tr').fadeOut(500); 
     return false; 
    }); 
+0

謝謝>>這個問題需要很長時間>>現在的工作 –