in this my code data is undefined why?
i can't access to data.message.
$.post("actions.php", {name_madan: madan , postaction:'sabte_madan' },
function(data){
if (data.success)
alert(data.message);
});
actions.php
case 'sabte_madan':
$query="SELECT * from maadan WHERE name_madan='{$_POST['name_madan']}'";
$result=$db->loadAssoc($db->setQuery($query));
if ( !$result )
{
$data['success']=true; $data['message']='ok';
}
else $data['success']=false; $data['message']='no';
break;
if ( isset ($data)) echo json_encode($data);
$datais only being set if!$result. Are you missing theelsepart of theifstatement?,'json'to your$.postto tell jQuery to parse it as JSON.if ( !$result ) { $data['success']=false; $data['message']='ok'; } else { $data['success']=true; }caseblock?dataundefinedness. Or it'sdata.successthat is nottruehere? Also, do you understand that your code is vulnerable to SQL injections?