ci 를 이요하여 ajax 관련 작업을 진행하고있는데
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* index.php
*
* @author KwonGunbo
*
*/
class Ajax extends CI_Controller {
public function getMapdateJson()
{
$this->load->model('map_model','',TRUE);
$data = $this->input->post();
$tp_code = $data['tp_code'];
$tp_code ="22";
//$result = $this->map_model->getMapData($this->input->get("tp_code"));
$result = $this->map_model->getMapData($tp_code);
$result = $this->services_json->encode($result);
$data['str'] = $result;
$this->load->view('/common/echo',$data);
}
}
ajax/getMapdateJson 호출시 <meta http....charset=utf-8">ajax데이터가 나옵니다.
실제 데이터
뷰를 로드하여 디스플레이 시킬 필요 없습니다.
데이터를 json 객체로 만드는 것 보니 응답데이터를 json로 받아와서 처리를 하시는 것 같은데;;
컨트롤러 상에서 바로 echo $result; 응답데이터를 내 보내면됩니다.
혹 json 데이터를 스트링으로 넘겨주려는 것이라면;; 굳이 뷰를 이용해 내보낼 필요는 없습니다.;;
만약 위와 같이 뷰를 이용해 내보야 한다면 뷰파일에서 json 객체만 출력하시면 됩니다.
그런데도 meta 태그 내용이 출력된다면 이는 어딘가에서 meta 태그를 생성하여 출력한다는 뜻으로 생각됩니다.