开发者

How do I render a single JSON value inside HTML?

开发者 https://www.devze.com 2022-12-10 00:37 出处:网络
When I return a JSon value, i simply want to put a string inside an existing div EDIT: Let me Rephrase this: I want my MVC controller to return a JSON object to the UpdateTarget specified in the MV开

When I return a JSon value, i simply want to put a string inside an existing div

EDIT: Let me Rephrase this: I want my MVC controller to return a JSON object to the UpdateTarget specified in the MV开发者_如何学编程C AJAX call. Instead of returning "content".


Assume your JSON String looks like this:

 var jobj = '{"name":"value"}';

and you have a div on the HTML with id mycontentdiv then

 document.getElementById("mycontentdiv").innerHTML = jobj.name;

will take the "value" and place it in the div.

Without further details it is difficult to be more specific.

0

精彩评论

暂无评论...
验证码 换一张
取 消