2017-02-06 6 views
0

このajaxリクエストを実行する前に確認ボックスを表示する必要があります。レコードを削除する前に確認ボックスを表示する方法

$(document).on("click", ".deletecustomer", function() { 
    var id = $(this).attr("id"); 
    $.ajax({ 
     method: "post", 
     url: "deletecustomer.php", 
     data: { 
      id: id 
     }, 
     success: function(data) { 
      console.log(data); 
      if (data == "success") { 
       window.location.href = "customer.php"; 
      } 
     } 
    }); 
}); 
+1

''(確認( 'あなたはよろしいですか?')){/ *アヤックス* /}もし? – Qirel

答えて

0
$(document).on("click", ".deletecustomer", function() { 
    if (confirm('Are you sure?')) { 
     var id = $(this).attr("id"); 
     $.ajax({ 
      method: "post", 
      url: "deletecustomer.php", 
      data: { 
       id: id 
      }, 
      success: function(data) { 
       console.log(data); 
       if (data == "success") { 
        window.location.href = "customer.php"; 
       } 
      } 
     }); 
    } 
}); 
+0

ありがとう!今、正確に作業しています... – user7525616

+0

あなたの質問に答えると、あなたは先に進み、この回答に完全な印を付けることができますか? –

関連する問題