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
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
Explore related questions
See similar questions with these tags.
lang-js