jquery - Can't achive a part of json encoded data -
i have response:
{"status":"succes","message":"some message!"}
all data.status or data.message undefinied...
success : function (data, status) { console.log(data); if(data.status=='error'){ console.log(data.message); //$('p.file_error').html(data.message); }else { console.log(data.message); } }
my controller has this:
$data['status']='error'; $data['message']='some message!'; echo json_encode($data);
you should have this, think you're missing datatype value should type "json" works properly.
$.ajax({ url : base_url() + '/controller/method', data : {param1: 'val1', "param2" : val2}, type: "post", datatype: "json", success: function(response) { console.log(response); }
Comments
Post a Comment