My Model-- iam getting data from Mysql database and returning it to controller
public function getCharges(){
$where = "charge_type = 'variable';
$data = $this->read('charges',$where);
return $data;
}
My Controller -- Here iam encoding the data in the json format to ajax
if (isset($_POST['method']) && $_POST['method'] == 'getCharges'){
$this->load->model('Apiweb_m');
$data = $this->Apiweb_m->getCharges();
echo json_encode($data);
}
My AJAX
var method = "getCharges";
$.ajax({
type: 'POST',
data: 'method='+method,
url : api_url+"apiweb",
/* dataType: "json",*/
success:function(msg){
var data = $.parseJSON(msg);
console.log(data);// here iam getting Parse error
},
error:function(Xhr, status, error){
console.log(Xhr);
console.log(status);
console.log(error);
}