douyingzhan5905 2014-02-03 20:07
浏览 39
已采纳

将HTML解码回由PHP发布的PHP中的原始HTML代码

There is a question on SO How to send HTML code in an http POST request? and works good in sending but receiving of HTML and decode it back to original HTML is not working

My HTML Code as

<div id="TypePostBox">
   <div style='margin-top:20px;'>Hello World</div>
</div>

Currently I am posting with JQuery with this code as suggested in above link

var cod = encodeURIComponent($('#TypePostBox').html());
//code to POST with jquery
console.log(cod);
//Output in console as %26lt%3Bdiv%20style%3D'margin-top%3A20px%3B'%26gt%3BHello%20World%26lt%3B%2Fdiv%26gt%3B

and receiving it in php as

echo rawurldecode($_POST['dt']);
//PHP Output as &lt;div style='margin-top:20px;'&gt;Hello World&lt;/div&gt;

How can I send and get the exact HTML Code? I want to POST not GET with Jquery / Javascript. I am ajaxing it.

I just want to send exact HTML and receive exact HTML, What can be done?

  • 写回答

2条回答 默认 最新

  • dongwo1914 2014-02-03 20:12
    关注

    I am pretty sure

    echo html_entity_decode(rawurldecode($_POST['dt']));
    

    does the job. See html_entity_decode.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错