我使用ajax发布一些数据,并希望更改按钮文本.我真的不知道从哪里开始.我到目前为止的代码如下:
$("input[type='button'][name='Subscribe']").click(function(e){
$.ajax({
type: "POST",
url: "test.php",
data:{
id: $(this).attr('id'),
idMembers: $(this).attr('idMembers')
},
success: function(msg){
alert("Subscribed");
}
})
});
Run Code Online (Sandbox Code Playgroud)
$("input[type='button'][name='Subscribe']").click(function(e){
$this = $(this);
$this.val("processing") // or: this.value = "processing";
$this.prop('disabled', true); // no double submit ;)
$.ajax({
type: "POST",
url: "test.php",
data:{
id: $this.attr('id'),
idMembers: $this.attr('idMembers')
},
success: function(msg){
alert("Subscribed");
$this.val("i'm finally done!"); // pfewww, that's was hard work!
}
})
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7192 次 |
| 最近记录: |