Friday, 15 February 2013

php - Javascript how to parse JSON with json array -



php - Javascript how to parse JSON with json array -

i want parse using jquery or javascript json generated php code follows:

json

{ "user": { "name": "john carter", "position": 0, "tickets": { "months": [ "october", "november" ], "start_time": "2014-10-02", "end_time": "2014-11-21", "open": [ "1", "3" ] } } }

my javascript

$.ajax({ url: 'ajax.report.php', type: 'post', data: 'start='+startdate+'&&end='+enddate, success: function(response){ var json_obj = $.parsejson(response); for(var =0; < json_obj.user.length; i++){ //what next? } } });

kindly help. give thanks !

the json returned jquery javascript object, not string. not have parse farther utilize it. i'm on mobile device right can't confirm, i'm pretty sure can this:

success: function(response){ //try var name = response.user.name //try var name = response.name }

you should able print out name string using console.log() after this.

javascript php jquery json

No comments:

Post a Comment