I hve problem with jquery, i have code php like this
if($record2==0)
{
if($tmp_curr==$curr)
{
$reqvendor->inserttmp($json);
$json[] = array('stat' => true, 'msg' => '');
//$app['data'] = true;
//var_dump($reqvendor->inserttmp($json));
}
else
{
$json[]= array('stat' => false, 'msg' => 'Currency not same');
//$app[0] ='satu';
}
}
else
{
$json[] = array('stat' => false, 'msg' => 'PO Allready Input, try another PO');
}
//var_dump($app);
echo json_encode($json);
and i have jquery like this
$.ajax
({
type: "POST",
url: host+"datatable/tmp_po",
data: dataString,
cache: false,
success: function(json)
{
if(json['stat']=="false")
{
swal({
title: json['msg'],
type : "warning"
});
}
else
{
$('#tbl_tmppo').DataTable().ajax.reload();
}
}
});
What i susposed is if json['stat'] is false, json['msg'] will show, but my problem is i cant call json['stat'] or json['msg'], it will always show undi
fined on console. If i console.log(json) it will show {"data":true,"msg":""}
How do i call json['stat'] or json['msg']? Did i'm doin worng on jquery or on php???
EDIT I try
json.stat reslust undefined
json[0] result "{" //dont why show that :/
json[stat] result not found
json["stat"] result undefined
json['stat'] result undefined
json resulst {"data":true,"msg":""}
UPDATE I'm using this solution Get data from php array - AJAX - jQuery. and it's work!!!