0
我有动态按钮,从数据库生成。 例如:点击后通过id删除元素
button 1, id=button1
button 2, id= button2
button 3, id= button3
..etc....
如果我点击按钮1,我的功能会送东西给mysql数据库,所以我叫AJAX。 但我想要的是:如何在进程发送到数据库完成后删除button1? 与其他按钮同样的事情(送东西到数据库,并删除按钮)
在我的按钮,我把的onClick这里
是我的代码:
<script>
function process(idbutton){
$.ajax({
type: "POST",
url: "http://urlofmysite.com/process.php?",
data: "pidd=" + idbutton,
cache: false,
success: function(html){
alert(html); //RESPONSE FROM SERVER
}
});
//REMOVING BUTTON
document.getElementById(+idbutton+).outerHTML="";
}
</script>
,但它使用犯规的jQuery Mobile的工作phonegap
谢谢
对不起,现在工作。我改变document.getElementById(+ idbutton +)。outerHTML =“”;到document.getElementById(idbutton).outerHTML =“”; – Def
只是把它放在你的''成功'回调'$('#'+ idbutton).remove()'中。这是更好的,因为你已经使用jQuery,也只有在成功调用你的url时才会删除按钮 –