I have a an array:
$result = array('statusAlert' => 'Your input was validated'
'input' => $input); // $input is a string
json_encode($result);
in jQuery, I want to alert ‘statusAlert’ and ‘input’ separately? How do I access them?
I tried alert(result.statusAlert), alert(result[0]), alert(result.statusAlert[0]) but none of them has worked.
Edit
I am trying to do that within the “success” callback function of ajax() in jQuery
When I alert(result), I get:
{"statusAlert":"Your input was validated","input":"this is the string input"}
Change your
.ajax()request to includedataType:'json'.