2012-06-21 3 views
0
//activate selected row in table 
jQuery('.activatebutton').click(function(){ 
    var tb = jQuery(this).attr('title'); 
    //initialize to false as no selected row 
    var sel = false; 
    //get each checkbox in a table 
    var ch = jQuery('#'+tb).find('tbody input[type=checkbox]'); 

    //check if there is/are selected row in table 
    ch.each(function(){ 
    if(jQuery(this).is(':checked')) { 
     //set to true if there is/are selected row 
     sel = true; 
    jQuery(this).parents('tr').fadeOut(function(){ 
     /* 
     THIS IS THE LINE THAT IS NOT WORKING BELOW!!!! I want to send VALUE ID to delete.php 
     */ 
     jQuery.get('delete.php', { id:this.id }); 
     //remove row when animation is finished 
     jQuery(this).remove(); 
    }); 
    } 
}); 
+0

당신은 delete.php가 요청되지 않았거나 id 매개 변수가 delete.php로 보내지지 않는다고 말하고 있습니까? – JeremyWeir

+0

나의 첫 번째 제안은 Console (Firefox & Firebug 또는 Chrome)이 있고'console.log ("ID ="+ this.id);''jQuery.get (' delete.php '...'. ID 값을 가져와 delete.php 스크립트로 보내면 무엇이 있는지 볼 수 있습니다. –

+0

@JeremyWeir delete.php는 요청하지 않고있을 수 있습니다. id 파라메터가 보내지지 않았기 때문에, 아마도? – user1470755

답변

1

정확히 어떤 속성을 보내고 싶은지는 분명하지 않지만 요소의 ID처럼 보입니다. 이 경우 보정이고, 여기 :

jQuery.get('delete.php', { id:this.id }); 

jQuery.get('delete.php', { id:jQuery(this).attr('id') }); 

그래서 당신은 요소의 id 속성을 보내드립니다해야합니다.

여전히 작동하지 않는 경우 삭제 스크립트의 잘못된 경로가있을 수 있습니다. chrome dev 도구 또는 방화 광이이를 ​​알려줍니다.

+0

jQuery 객체를 호출하지 않고 id에 액세스 할 수 있습니다. (사실,'jQuery (this) .attr ('id')')보다는'this.id'를 사용하는 것이 약간 빠릅니다. 따라서 이것은 잘못된 해결책입니다. - http://stackoverflow.com/questions/4651923/when-to-use-vanilla-javascript-vs-jquery –

+0

참을보십시오. 그게 내 마음을 미끄러 져. 내 대답의 두 번째 부분에 조금 더 가야한다 :) – unceus

관련 문제