질문Q #3188
ajax - datatype:json 질문입니다.
zlghzh2015-06-09 11:59:02
스크립트
<script type="text/javascript">
$('#question-send').on('click',function(){
alert("ajax 이전");
$.ajax({
url:'<?php echo base_url();?>ajax/question_send',
type:'POST',
dataType:'json',
data:$('#mento-question-send').serialize(),
success:function(data){
alert("완료");
},error:function(request,status,error){
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
}
})
})
</script>
콘트롤러
public function question_send(){
$url = base_url();
$this->load->library('form_validation');
$this->load->helper('alert');
$this->form_validation->set_rules('subject', '제목', 'required');
$this->form_validation->set_rules('content', '내용', 'required');
echo '<meta http-equiv="Content-Type" content="text/html; charset=uft-8" />';
if($this->form_validation->run() == TRUE){
//alert('성공', 'main');
}else{
echo json_encode(array('id'=>"success"));
}
ajax 에러 메서지
code:200
message:<br/>
<p>Parse error</b>:syntax error, unexpected end of file, expecting function(T_FUNCTION) in <b>C:주소OOO~~\ajax.php</b>on line <b> 55</b><br/>
error:SyntaxError : Unexpected token <
이런 메세지가 뜨는데 왜 이러건가요 ㅜㅜ
신입이라 잘모르겠네요 ㅜㅜ