2013-05-14 96 views
0

我正在使用此類來設置是/否警報。jquery確認操作不起作用

http://myclabs.github.io/jquery.confirm/

這是我的代碼:

var currentId; 

$(".confirm").click(function() { 
    currentId = $(this).attr('id'); 
}); 

$(".confirm").confirm({ 
    text: "Are you sure?", 
    confirm: function(button) { 
        //if I alert here currentId, it alerts right 
     $.post("receive.php", { currentId: "id"}) 
     .done(function(data) { 
      alert(data); //NOTHING!!! 
     }); 
    }, 
    cancel: function(button) { 
     $('.modal hide fade').css("display", "none"); 
    }, 
    confirmButton: "Yes", 
    cancelButton: "No!", 
    post: true 
}); 
}); 

Receive.php

<? echo $_POST['id']; ?> 
+1

問題是什麼? – 2013-05-14 15:19:25

+0

你有太多'});'s – 2013-05-14 15:20:52

回答

4
$.post("receive.php", { currentId: "id"}) 

應該

$.post("receive.php", { id: currentId }) 
+0

謝謝!我認爲那很好,但現在我發現我錯了;) – wemakenever 2013-05-14 15:22:17