我已经编写了简单的ajax代码,在成功回调中我写了一个警报,但它不起作用。即使响应http状态为200,也会执行jquery ajax错误回调
的代码是:
$(".change_forex_transaction_status").click(function(){
$("#insufficient_funds").css("display","none");
var id = $(this).attr('data-transaction_id');
//var ttype = $(this).attr('data-ttype');
if (confirm("Are you sure you want to mark this transaction as complete?")) {
$(this).unbind("click");
$.ajax({
url:"<?php echo Yii::app()->getBaseUrl(true);?>/customer/changeForexTransactionStatus",
type:"POST",
dataType: "json",
//data:{id:id,tidentify:2,ttype:ttype},
data:{id:id,tidentify:2},
success:function(res){
if(res == "unauthorized"){
alert("You Are not authorize to perform this action.");
}else{
if(res == "success"){
location.reload();
} else if(res == "insufficient_fund"){
alert('Insufficient Fees');
$("#insufficient_funds").css("display","block");
} else if(res == 'invalid_fee_account'){
alert('Invalid Merchant Fees Account');
}
}
},
error:function(t) {
console.log(t);
}
});
}
});
即使响应HTTP状态代码是200,它进入错误回调,而它应该去的成功回调,并打开一个警告框。
任何人都可以请帮忙。
所以....它显示什么错误?还有什么显示在控制台中,还有其他错误或消息? –