簡體   English   中英

檢查是否刪除成功消息php ajax jquery mysql

[英]check if delete was successful message php ajax jquery mysql

嗨,大家好,我什至成功刪除了消息,返回false刪除消息(“無法刪除”),除了成功刪除消息,而且查詢還在,請告訴我我在做什么錯了,這是我的代碼\\

delete.php

  if(isset($_POST['delete_id']) && !empty($_POST['delete_id'])) {
          $delete_id = mysql_real_escape_string($_POST['delete_id']);
    $query=mysql_query("DELETE FROM color WHERE idColor='$delete_id'");
    if($query != false) {
            echo 'true';
          }
    mysql_close();
<script>
 $(document).ready(function(){
        $('.del_btn').click(function(){
        if (confirm("Are you sure you want to delete this Color?"))
       var del_id = $(this).attr('rel');
              $.post('script/delete_color.php', {delete_id:del_id}, function(data) {
          if(data == 'true') {
            $('#'+del_id).remove();alert('Color has been deleted!');
          }
           else {
            alert('Color could not delete!');
          }
                document.messages.submit();
            return false; // This line added}
    });
    }); 
    });

</script>

我不太了解您的問題,但是我將進行有根據的猜測...

您需要將邏輯包裝在“ confirm” IF語句中。 另外,您還有一個額外的“});”。

$(document).ready(function(){

    $('.del_btn').click(function() {

        if (confirm("Are you sure you want to delete this Color?")) {

            var del_id = $(this).attr('rel');

            $.post('script/delete_color.php', {delete_id:del_id}, function(data) {

                if(data == 'true') {
                    $('#'+del_id).remove();alert('Color has been deleted!');
                } else {
                    alert('Color could not delete!');
                }

                document.messages.submit();
                return false; // This line added
            }
        }
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM