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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -