gpt4 book ai didi

javascript - 如何在页面中将其添加为html

转载 作者:行者123 更新时间:2023-11-30 09:00:50 26 4
gpt4 key购买 nike

这是一个在 ajax 调用中获取的数据。它应该是html。如何将其作为 html 添加到 div 中?我认为字符以安全格式返回。有没有办法通过 javascript 或 php 打印它?

       \n     \n\u003Cscript type=\u0022text\/javascript\u0022\u003E\nvar qid =  28;\n\n\u003C
\/script\u003E \n\n\u003Ca href=\u0022#\u0022 class=\u0022test\u0022\u003ETest\u003C
\/a\u003E\n \n\u003Cdiv class=\u0022findme view view-test-mode view-id-test_mode
view-display-id-page view-dom-id-1\u0022\u003E\n \n \n \n \u003Cdiv
class=\u0022questions\u0022\u003E\n \u003Ch1 class=\u0022question\u0022\u003EWhich of
the following proves or disproves a specific act through oral testimony based on
information gathered through the witness\u0027s five senses?\u003C\/h1\u003E
\n\t\u003Cdiv class=\u0022options\u0022\u003E\n\t\u003Cinput id=\u00221\u0022type=\u0022radio\u0022
name=\u0022answer\u0022 value=\u0022Circumstantial evidence.\u0022 \/\u003ECircumstantial
evidence.\u003Cbr\/\u003E\u003Cinput id=\u00222\u0022type=\u0022radio\u0022
name=\u0022answer\u0022 value=\u0022Corroborative evidence.\u0022 \/\u003ECorroborative
evidence.\u003Cbr\/\u003E\u003Cinput id=\u00223\u0022type=\u0022radio\u0022
name=\u0022answer\u0022 value=\u0022Direct evidence.\u0022 \/\u003EDirect evidence.\u003Cbr\/\u003E\u003Cinput id=\u00224\u0022type=\u0022radio\u0022
name=\u0022answer\u0022 value=\u0022Conclusive evidence.\u0022 \/\u003EConclusive
evidence.\u003Cbr\/\u003E\t\n\t\t\n\t\u003C\/div\u003E\n\t \u003C\/div\u003E\n \n
\n\t\n \u003Cdiv class=\u0022item-list\u0022\u003E\u003Cul class=\u0022pager\u0022\u003E
\u003Cli class=\u0022pager-previous first\u0022\u003E\u003Ca href=\u0022\/qengine
\/test?page=5\u0022 class=\u0022active\u0022\u003E\u2039\u2039\u003C\/a\u003E\u003C
\/li\u003E\n\u003Cli class=\u0022pager-current\u0022\u003E7 of 29\u003C\/li\u003E
\n\u003Cli class=\u0022pager-next last\u0022\u003E\u003Ca href=\u0022\/qengine\/test?page=7
\u0022 class=\u0022active\u0022\u003E\u203a\u203a\u003C\/a\u003E\u003C\/li\u003E\n\u003C
\/ul\u003E\u003C\/div\u003E\n \n \n \n\n \n \u003C!--Total: 29done : 7--\u003E\u003Ca
href=\u0022#back\u0022 class=\u0022back\u0022\u003EBack\u003C\/a\u003E|\u003Ca
href=\u0022#next\u0022 class=\u0022next\u0022\u003ENext\u003C\/a\u003E | \u003Ca
href=\u0022results\u0022 class=\u0022result\u0022\u003EEnd Test \u0026 Show Results\u003C
\/a\u003E\t\u003Cbr\/\u003E\u003Cbr\/\u003E\n\t\u003Cinput type=\u0022checkbox\u0022
name=\u0022mark\u0022 value=\u0022marked\u0022 class=\u0022mark\u0022\/\u003E Mark For
Review \n \n \n \n \n \n\u003C\/div\u003E

最佳答案

字符以转义的 unicode 格式返回。您可以使用此函数将其编码为 UTF8:

function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}

例如:

encode_utf8( '\u003Cscript type=\u0022text\/javascript\u0022\u003E' ); -> '<script type="text/javascript">'

关于javascript - 如何在页面中将其添加为html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9453507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com