Jquery ajax success function returns null?
- by udaya
I use the following the jquery statements to call my php controller function, it gets called but my result is not returned to my success function....
function getRecordspage() {
$.ajax({
type: "POST",
url:"http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount",
data: "{}",
contentType: "application/json; charset=utf-8",
global:false,
async: true,
dataType: "json",
success: function(result) {
alert(result);
}
});
}
My controller method,
function mainAccount()
{
$_SESSION['menu'] = 'finance';
$data['account'] = $this->adminmodel->getaccountDetails();
if(empty($data['account']))
{
$data['comment'] = 'No record found !';
}
$json = json_encode($data);
return $json;
}
I get the alert(1); in my success function but my alert(result); show null... Any suggestion...