質問

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?

役に立ちましたか?

解決

I am pretty sure

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

does the job. See html_entity_decode.

他のヒント

Post an echo of the post['dt'] with out using the rawurldecode

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top