?Briella 2014-07-22 09:47 采纳率: 0%
浏览 21

刷新div面板

I am trying to delete a button on click from a layout itself . but unable to do it so far . I am new to ajax and jQuery . I have a div on web page showing pending actions in the form of buttons now I want to remove each button when user clicks on it. this web page is auto refreshed in every 1 minute and all these pending actions are stored in a session variable .

now I am not getting a way to send this button id to another php script so that it can delete it from session array.

I tried following ..

     <script type='text/javascript'src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> 
    function HideButton(butId)
      {
        $('#'+butId).hide();
        deleteButton(butId);

      }
    </script>


 <script>
 function deleteButton(id) {
     $.ajax({
      url: "delete_button.php",
      type: "POST",
      data: "id=" + id,
      success: function(response) {// Response handler}
   }); 
 }
 </script>

 <?php  // here is my php code ..

 //displaying button as follows in a loop 
 echo "<br><button type='button' id='".$id."' onclick=javascript:HideButton('".$id."') >".$pendingAction[$id]." </button>";

did not found any success yet.

  • 写回答

3条回答 默认 最新

  • weixin_33734785 2014-07-22 09:50
    关注

    use the jQuery remove

    DOM:

    <div class="container">
    <div class="hello">Hello</div>
    <div class="goodbye">Goodbye</div>
    </div>
    

    jQuery:

    $( ".hello" ).remove();
    

    Output:

    <div class="container">
      <div class="goodbye">Goodbye</div>
    </div>
    
    评论

报告相同问题?