Php “仅警报”;讯息;{success";:“false";,“message";:“信用卡号无效”的部分
正如你可以从标题中看到的,我想弹出一个提示显示“信用卡号无效” 我目前正在使用alert(data.responseText);但显示“当信用卡号码与订阅关联时,无法将其更新为不受支持的卡类型。Php “仅警报”;讯息;{success";:“false";,“message";:“信用卡号无效”的部分,php,ajax,json,Php,Ajax,Json,正如你可以从标题中看到的,我想弹出一个提示显示“信用卡号无效” 我目前正在使用alert(data.responseText);但显示“当信用卡号码与订阅关联时,无法将其更新为不受支持的卡类型。此商户帐户不接受信用卡类型。信用卡号码无效。{“成功”:“错误”,“消息”:“信用卡号码无效”。}” 有没有办法只显示“信用卡号无效”部分 如果我使用alert(data.Message));给出“未定义”和警报(数据);给出“[对象]” 谢谢你的帮助 var data = {
此商户帐户不接受信用卡类型。
信用卡号码无效。
{“成功”:“错误”,“消息”:“信用卡号码无效”。}” 有没有办法只显示“信用卡号无效”部分 如果我使用alert(data.Message));给出“未定义”和警报(数据);给出“[对象]” 谢谢你的帮助
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;
}
}其他{
foreach($result->errors->deepAll()作为$error){
$errorFound=$error->message.“
”;
回声$errorFound;
}
$response=array(“success”=>“false”,“message”=>$errorFound);
返回$response;
出口
}
实际上,您在ajax请求中设置了响应类型“json”,但在“json”中没有得到响应。在php脚本中使用json_encode函数返回json响应
return json_encode(response);
然后警惕
alert(data.message);
警报(data.message)代码>?您在警报前的行中的数据['message']
如何?如果您指的是警报(数据['message'];