【发布时间】:2015-06-30 00:51:41
【问题描述】:
从标题中可以看出,我希望弹出警报显示“信用卡号无效。”
我目前正在使用 alert(data.responseText);但显示“信用卡号在与订阅相关联时无法更新为不支持的卡类型。
此商家帐户不接受信用卡类型。
信用卡号无效。
{” success":"false","message":"信用卡号无效。"}"
有没有办法只显示“信用卡号无效”部分。
如果我使用 alert(data.Message));给出“未定义”和警报(数据);给出“[object Object]”。
感谢您的帮助。
var data = {
"action": "checkout"
};
data = $('#checkout_form').serialize() + "&" + $.param(data);
$.ajax({
type: "POST",
dataType: "json",
url: "inc/placeorder.php", //Relative or absolute path to response.php file
data: data,
success: function(data) {
if(data["success"] == 'true'){
$("#placeorder").attr("disabled",false);
$(".payment_loader").fadeOut("slow").hide();
$('#checkout_form').trigger("reset");
window.location = "order_success.php";
}
if(data["success"] == 'false'){
$("#placeorder").attr("disabled",true);
$(".payment_loader").fadeOut("slow").hide();
$('#subscribe_response').html(data['message']);
alert(data.responseText);
}
},
error: function(data, status){
alert(data);
console.log("error", data.responseText);
console.log("error", status.responseText);
}
});
}else{
return false;
}
});
编辑
这是被抛出的错误。
} else {
foreach ($result->errors->deepAll() as $error) {
$errorFound = $error->message . "<br />";
echo $errorFound;
}
$response = array("success" => "false", "message" => $errorFound);
return $response;
exit;
}
【问题讨论】:
-
alert(data.message);? -
提醒前行中的
data['message']怎么样? -
如果你的意思是 alert(data['message'];