2013-04-29 73 views
0

我正在使用酒店Api提供程序作为Json响应发送回我的应用程序包含字符串的Json节点。 该字符串里面者正在使用一些HTML格式是这样的:如何使用html格式我从Json Web Response获取?

"shortDescription": "<p><b>Location. </b> <br />The Edgewater - A Noble House Hotel is a business-friendly hotel located in central Seattle, close to Odyssey - The Maritime Discovery Center, Washington State Convention &" 

当我想在我JSPX页面使用此字段,一个表格单元格内,我得到的原始文本,不进行格式化,并与所有的段落和粗体标签。 有什么办法可以强制我的jspx页面显示这种格式? 谢谢。

+0

请出示你的代码使用指定的“SHORTDESCRIPTION”到'表格单元格'在你的页面中。 – 2013-04-29 14:01:09

+0

你能显示你的代码吗? – Ventura 2013-04-29 14:01:21

回答

0

基本上你想用新内容替换旧内容。你可以使用jQuery.replaceWith

当你得到的回应JSON,你可以,例如,用包含新数据的新行替换下讨论的行:

var rep = "<tr id='id-to-replace'><td>Description</td><td>" + responseJSON.description + "</td></tr>"; 
$('#id-to-replace').replaceWith(rep);