Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将json字符串中的HTML标记解析为jquery_Javascript_Jquery - Fatal编程技术网

Javascript 如何将json字符串中的HTML标记解析为jquery

Javascript 如何将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

我从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>","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":"&#8226; Laparoscopyæ causes increased PCWP, Intra cranial Pressure and decreased Functional Residual capacity after expiration is decreased after laparoscopy gas insuffulation.<br \/>&#8226; 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是什么元素类型