为什么下面的代码不能正常工作?我只需要通过点击btn上的javascript id内容发布。这段代码在许多其他情况下都能正常工作,但这里我使用的是twitter引导模式。谢谢。
<button id="<?php echo $id; ?>" class="btn btn-warning" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<span class="glyphicon glyphicon-trash"></span> delete id
</button>
<script type="text/javascript">
//delete id
$(document).on('click','.btn-warning',function(){
var element = $(this);
var del_id = element.attr("id");
var info = 'id=' + del_id;
if(confirm("are you sure ?")){
$.ajax({
type: "POST",
url: "page.php",
data: info,
success: function(){ window.location.href = "/logout.php"; }
});
}
return false;
});
</script>
PHP
if($_POST['id']){
$id=$_POST['id'];
$id = mysql_real_escape_string($id);
...
发布于 2014-02-07 21:46:28
info = {'id' : del_id };
尝试以数组形式发送数据。
https://stackoverflow.com/questions/21613963
复制相似问题