Wednesday, 15 February 2012

jQuery is Commenting out my PHP Code Snippets -



jQuery is Commenting out my PHP Code Snippets -

i'm building code snippet scheme , using jquery display editor. noticed jquery likes comment out inline php code. there way prevent happening:

<textarea id='beep'></textarea>

jquery code:

var code = "<div>why <?php echo 'hello'; ?> there!</div>"; var parsed = $(code).html(); $('#beep').val(parsed);

this see in textarea:

why <?php echo 'hello'; ?> there!

but instead jquery modifies this:

why <!--?php echo 'hello'; ?--> there!

i understand security measure, there way stop happening?

i know can utilize html entities around this, due nature of tool interfere code snippets beingness posted intentionally include html entities.

jsfiddle: http://jsfiddle.net/yb4fd/1/

additional node: answers suggest utilize javascript handle without jquery, need jquery. string contains dom tree i'm using jquery parse.

try this:

var code = "<div>why &lt;?php echo 'hello'; ?&gt; there!</div>";

php jquery code-snippets

No comments:

Post a Comment