도움이 필요합니다! Codeigniter 서버에서 json 데이터를 가져 오려고합니다. 난 JS 에러html 로컬 파일의 jquery로 json 데이터 가져 오기
와 JSON 데이터 응답을 구하는 본public function index()
{
$type_message = 'success';
$message = 'Mobile plateform';
$this->output->set_header("Access-Control-Allow-Origin: *");
$this->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
$this->output->set_status_header(200);
$this->output->set_content_type('application/json');
$this->output->_display();
echo json_encode(array('type_message' => $type_message, 'message' => $message));
}
등
$.ajax({
type: "POST",
url : serverUrl+'mobcontroller/users/',
crossDomain: true,
async: false,
data : $("#formlogin").serialize(),
dataType : MobileJsonType[1],
beforeSend : function(){//do stuff here},
success : function(responseData) {
alert(JSON.stringify(responseData));
},
error : function(jqXHR, textStatus, errorThrown) {
// do stuff here
},
complete: function(xhr, settings){
alert(JSON.stringify(xhr)+'\n'+settings);
}
});
이그나이터 제어기 보면 : 이 내 HTML 로컬 파일 (//myproject/index.html d)이며
Uncaught SyntaxError: Unexpected token :
도와주세요!
시도해보십시오. 성공 : function (responseData) {alert (responseData.type_message);}. 가정 MobileJsonType [1] 값'json' –