Backend/PHP

Ajax + JSON

Jeffrey Oh 2019. 6. 20. 19:10

Controller


// json 설정
$this->output->set_header('Content-Type: application/json; charset=utf-8');
echo json_encode(array("rt" => "OK"));
exit;



Ajax

$.post(ROOT_URL + "member/certification_ok", {email: email_val, userName: userName_val}, function(json) {
    if(json.rt == "OK") {
        alert(json);
    }
}); // End $.post Ajax