PHP로 배열 형식으로 아약스 응답을 받고 있어요. jQuery에서 배열 응답 값을 추출하는 방법? 는 참고 :PHP : ajax 배열 응답을 추출하는 방법
PHP 배열은 다음과 같습니다
$response = array('msg' => 'Hello', 'html' => '<b>Good bye</b>');
내가 내 아약스 응답에 $ 응답 배열을 얻고있다. 즉
var promo = "promo=45fdf4684sfd";
$.ajax({
type: "POST",
url: baseJsUrl + "https://stackoverflow.com/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.
}
});
답장을 보내주십시오. 감사합니다. .
분명히하기 위해 echo json_encode ($ response); –
알렉스가 맞습니다. php 배열을 편집했습니다. – gautamlakum
Downvoter 문제를 말해주십시오 :) – alex