【发布时间】:2023-04-04 00:00:02
【问题描述】:
我从 php url 获得数组格式的 ajax 响应。如何在jQuery中提取数组响应值? 仅供参考:
PHP 数组是:
$response = array('msg' => 'Hello', 'html' => '<b>Good bye</b>');
我在我的 ajax 响应中得到了 $response 数组。即
var promo = "promo=45fdf4684sfd";
$.ajax({
type: "POST",
url: baseJsUrl + "/users/calc_discount",
data: promo,
success: function (msg) { // I am getting $response here as ajax response.
//alert(msg);
// Here I want to check whether response is in array format or not. if it is in array format, I want to extract msg here and want to use response array values.
}
});
请告诉我答案。 谢谢。
【问题讨论】:
标签: php javascript jquery ajax arrays