Deepika Raturi
Deepika Raturi

Reputation: 29

read json array data from ajax response

Read json data value.
Getting the following result(json encoded)

    [{"client_id":1,"client_first_name":"Pooja"}]null

    how can i read "client_first_name" value. 
        $.ajax({
                    type: "POST",
                    data: {id: clientid},
                    dataType: 'json',
                    url: webURL + "/invoice/clientdetail/",
                    success: function(data)
                    {
                        var res = json_encode(data);

                    }
            });

 how can i read "client_first_name" value 

*data- getting json array, how can i read particular value.

Upvotes: 0

Views: 4660

Answers (2)

Calin Vlasin
Calin Vlasin

Reputation: 1443

Assuming that your "res" jSON looks something like this:

{"client_first_name":"value"}

You are reading the value in this way:

res[0]['client_first_name']

Please reffer to:

how to get data to javascript from php using json_encode?

Upvotes: 2

Rupal
Rupal

Reputation: 1109

Use this to get client first name

res[0]['client_first_name']

Upvotes: 0

Related Questions