views:

70

answers:

2

I'm getting a JSON response from the server. Inside that JSON string I have HTML content which I need to display in a field. How do I do this?

A: 

Is this what you need? What kind of field? If it's a div or p

var yourContent = "";
$(".selector").html(yourContent);

If it's textbox use

$(".selector").val(yourContent);

That's of course if you using jQuery

Leon
A: 

If the JSON result is say:

({
name: 'John'
})

We grab it and operate on it like so:

$.getJSON("http://yourjsonresource",
        function(data){
            $('h1#foo').text( data.name );
        }
);
meder