在点击更新按钮块/解锁用户的状态后,在调用功能(查询更新)后出现问题。使用ajax它返回 “成功”,什么都不应该发生。如果我手动刷新页面,则显示更新的信息。我想在返回ajax响应“成功”后在表中显示我的更新记录。请建议我。
enter code here
$(document).ready(function(){
$(".blockUser").click(function(e){
if(confirm("Are sure want to Block this User")){
var msg=prompt("Please Enter your message");
var txt= $.trim( msg );
if(txt){
blockUser=this.id;
var loginUserId=document.getElementById('loginUserId').value;
var info='blockUser=' +blockUser;
$.ajax({
type: "POST",
url: "ajaxCall.php",
data:{loginUserId: loginUserId,blockUser: blockUser,message: msg},
success:function(data)
{
localtion.reload(0);
alert("User block successfully");
}
});
}
}
});
$(".UnblockUser").click(function(e)
{
if (confirm("Are you sure you want to UnBlock User")) {
UnblockUser=this.id;
var loginUserId=document.getElementById('loginUserId').value;
$.ajax({
type: "POST",
url: "ajaxCall.php",
data: {loginUserId: loginUserId,UnblockUser: UnblockUser},
success: function(data)
{
localtion.reload(0);
alert("User UnBlock successfully");
}
});
}
});
});
答案 0 :(得分:0)
$(document).ready(function(){
$(".blockUser").click(function(e){
var text = $(e.target).text();
if(text == 'Block'){
if(confirm("Are sure want to Block this User")){
var msg=prompt("Please Enter your message");
var txt= $.trim( msg );
if(txt){
blockUser=this.id;
var loginUserId=document.getElementById('loginUserId').value;
var info='blockUser=' +blockUser;
$.ajax({
type: "POST",
url: "ajaxCall.php",
data:{loginUserId: loginUserId,blockUser: blockUser,message: msg},
success:function(data)
{
$("#"+blockUser).text("Unblock");
$("#"+blockUser).removeClass("btn-success").addClass("btn-danger");
//localtion.reload(0);
//$("#blockrow"+blockUser+"").replaceWith(data);
alert("User block successfully");
}
});
}
}
}
if(text == 'UnBlock'){
if (confirm("Are you sure you want to UnBlock User")) {
UnblockUser=this.id;
alert(UnblockUser);
var loginUserId=document.getElementById('loginUserId').value;
$.ajax({
type: "POST",
url: "ajaxCall.php",
data: {loginUserId: loginUserId,UnblockUser: UnblockUser},
success: function(data)
{
//localtion.reload(0);
alert("User UnBlock successfully");
$("#"+UnblockUser).text("Block");
$("#"+UnblockUser).removeClass("btn-danger").addClass(" btn-success");
// $("#blockrow"+UnblockUser+"").replaceWith(data);
}
});
}
}
});
});