Javascript 如何将json字符串中的HTML标记解析为jquery
我从PHP获得以下jsonJavascript 如何将json字符串中的HTML标记解析为jquery,javascript,jquery,Javascript,Jquery,我从PHP获得以下json [{"autoid":"2","package_id":"a78o5jax32","chapter_title":"General Aspects of Surgery","question_text":"Capsule Endoscopy-False statement is","explanation":"<p>Capsuleê Endoscopy is not suitable for patients with strictures.<\/p
[{"autoid":"2","package_id":"a78o5jax32","chapter_title":"General Aspects of Surgery","question_text":"Capsule Endoscopy-False statement is","explanation":"<p>Capsuleê Endoscopy is not suitable for patients with strictures.<\/p>","reference":"Bailey and Love 26th Edition P\/205","options":"Sedation Not RequiredxxxxxxPainless ProcedurexxxxxxVisualize Entire small BowelxxxxxxSuitable For Patients With Stricture Bowel","answer":"3"},{"autoid":"3","package_id":"a78o5jax33","chapter_title":"General Aspects of Surgery","question_text":"Physiological changes in laparoscopy include all excep","explanation":"• Laparoscopyæ causes increased PCWP, Intra cranial Pressure and decreased Functional Residual capacity after expiration is decreased after laparoscopy gas insuffulation.<br \/>• There will be Hypercarbia and acidosis (pH decrease)<br \/>","reference":"Ref: Schwartz Page 417\/ 10th Edition","options":"Increases PCWPxxxxxxIncreased ICPxxxxxxDecreased FRCxxxxxxIncreased pH","answer":"4"}]
但是它显示胶囊内镜不适合狭窄患者。在HTML文档中
请帮助这可能是因为段落元素的结束标记在JSON数据中转义:
。尝试修改它以返回结束标记,如
发件人:
"explanation": "<p>Capsuleê Endoscopy is not suitable for patients with strictures.<\/p>"
"explanation": "<p>Capsuleê Endoscopy is not suitable for patients with strictures.</p>"
“解释”:“胶囊内镜不适合狭窄患者。”
至:
"explanation": "<p>Capsuleê Endoscopy is not suitable for patients with strictures.<\/p>"
"explanation": "<p>Capsuleê Endoscopy is not suitable for patients with strictures.</p>"
“解释”:“胶囊内镜不适合狭窄患者。”
我知道这和你的不同
但它似乎工作正常
希望它对您有所帮助作为一种选择,您可以始终使用早已被遗忘的纯Javascript:
$("#explanationTest")[0].innerHTML(explainText)
// OR
document.getElementById('explanationTest').innerHTML(explainText)
explanationTest是什么元素类型