Anuj TBE Anuj TBE - 1 year ago 104
jQuery Question

print json object in ajax response

I am using ajax to submit form and print response code.

This is php response array

$response['code'] = 401;
$response['message'] = 'Thank You';
$response['class'] = 'alert-success';
echo json_encode($response);

and this is ajax code

dataType: 'json',
type: 'POST',
url: '/sellers/php-page',
data: dataString,
cache: false,
success: function(d) {

output of

Object { code: 401, message: "Thank You", class: "alert-success" }

Now I have to print only message. How could I print/use single object out of array object ?

Answer Source
  success: function(d) {
     console.log(d.message);   // "Thank You"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download