Reputation: 5792
I have an array like this:
[{"City":"TORONTO ","FSA":"M5T","Province":"ON\r"}]
I am getting this data from,
echo json_encode($data);
I want to put city and province in text field through ajax jquery success.
I tried this in jquery success:
data = JQuery.parseJSON(data);
$('txtCity').val(data.City);
But, I am not getting actual data.
Upvotes: 1
Views: 135
Reputation: 67217
You have an array
.
Try this,
data = JQuery.parseJSON(data);
$('txtCity').val(data[0].City);
Upvotes: 2