개발 Q&A

제목 ajax - datatype:json 질문입니다.
글쓴이 zlghzh 작성시각 2015/06/09 11:59:02
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 16403   RSS
스크립트
<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 < 

이런 메세지가 뜨는데 왜 이러건가요 ㅜㅜ
신입이라 잘모르겠네요 ㅜㅜ
 다음글 node.js와 php 연동에 관해 질문합니다.. (3)
 이전글 관련 jqueryui나 라이브러리가 있나요? (1)

댓글

taegon / 2015/06/09 12:14:23 / 추천 0
에러 내용에는 ajax.php의 55번 줄에서 Syntax Error가 발생한거네요.. 55번줄에 코딩을 확인해보세요.
zlghzh / 2015/06/09 13:41:59 / 추천 0

} 하나 빼먹을 것과,

   echo '<meta http-equiv="Content-Type" c charset=uft-8" />';  <- 이 부분을 지우니 정상으로 되네요 ^^;;