我有这个调用 ajax,为了成功,我从 php 打印另一个按钮,它有另一个调用 ajax。如何在.on 之后不再次插入整个调用ajax 来使用方法.on?
阿贾克斯
$('.send_request').click(function(){ // send request ajax
var id_user_receive = $(this).attr('id');
var button = $(this);
$.ajax({
url: CI_ROOT + 'friendship_ctr/send_request',
type: "POST",
data: "id_user_receive=" + id_user_receive,
dataType: "html",
success: function(html) {
$('.button-option').html(html);
$('.remove_u').on('click',function(){
$('.remove_u').click(function(){ // i would like short this code
var id_user_receive = $(this).attr('id');
$.ajax({
url: CI_ROOT + 'friendship_ctr/remove_friend',
type: "POST",
data: "id_user_receive=" + id_user_receive,
dataType: "html",
success: function(html) {
},
error: function(status) {
alert(status);
}
});
});
},
error: function(status) {
alert(status);
}
});
});
});