1

How can i return json data to a razor view.

at the moment i can send it something like this:

i am assigning it to a hidden field:

"[{"title":"aa","description":"bb"},{"title":"cc","description":"dd"},{"title":"ee","description":"ff"}]"

but it just appears as a string when i do:

var places = $('#hidden-places').val();

how do i make it so that places is not like a string? but an array.

asked Feb 22, 2011 at 22:23

1 Answer 1

3

You could use the .parseJSON() function:

var places = $.parseJSON($('#hidden-places').val());
alert(places[0].title); // should alert 'aa'
answered Feb 22, 2011 at 22:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.