1

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.

1
  • 2
    It seems like an array so did you try data[0].City ?? Commented Dec 10, 2013 at 18:41

1 Answer 1

2

You have an array.

Try this,

data = JQuery.parseJSON(data);
$('txtCity').val(data[0].City);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.