CodeIgniter - 如何从控制器返回 Json 响应
2022-08-30 12:31:27
如何将来自控制器的响应返回到Jquery Javascript?
Javascript
$('.signinform').submit(function() {
$(this).ajaxSubmit({
type : "POST",
url: 'index.php/user/signin', // target element(s) to be updated with server response
cache : false,
success : onSuccessRegistered,
error: onFailRegistered
});
return false;
});
数据返回空(空白)!
function onSuccessRegistered(data){
alert(data);
};
控制器 -
public function signin() {
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode( $arr );
}