jqueryhtmlserializationuriencoding

how to unscramble html after "jquery serialize form"


OK I guess it's not a matter of scrambling as much as encoding... But when I take HTML from a form field and pass it through jQuery serialize, all the special characters get changed so if I want to output the HTML as actual HTML to be rendered as such in browser, what is the easiest way?

So this...

<div id="object_01" class="object_textbox ui-draggable ui-resizable" namn="object_01" style="z-index: 1; font-family: Arial;"><div class="object_inner" style="border:solid 1px #000;background-color:#fff;border-radius:100%;"></div><div class="ui-resizable-handle ui-resizable-e" style="z-index: 1000;"></div><div class="ui-resizable-handle ui-resizable-s" style="z-index: 1000;"></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 1000;"></div></div>

Turns something like...

%0D%0A%09%09%3Cdiv+id%3D%22object_01%22+class%3D%22object_textbox%22+namn%3D%22object_01%22+style%3D%22z-index%3A+1%3B+font-family%3A+Arial%3B%22%3E%3Cdiv+class%3D%22object_inner%22+style%3D%22border%3A+1px+solid+rgb(0%2C+0%2C+0)%3B+background-color%3A+rgb(255%2C+255%2C+255)%3B+border-top-left-radius%3A+100%25%3B+border-top-right-radius%3A+100%25%3B+border-bottom-right-radius%3A+100%25%3B+border-bottom-left-radius%3A+100%25%3B+cursor%3A+move%3B%22%3E%3C%2Fdiv%3E%3C%2Fdiv%3E

Solution

  • As the comment trail on this question suggests, the php method urldecode() is the way to restore all spoecial chars to the string for HTML rendering.