javascript - String cannot be parsed to HTML -


i have weird problem php , javascript files. have html content in database, , want insert page. so, values , pass html page this:

$string = preg_replace( "/\r|\n/", "", htmlentities($formcontent) ); 

i string can use pass javascript, this:

var contentform = '<?php echo $string; ?>'; 

now want insert html page. i've got div set up, if insert it, keeps getting treated string there isn't dom display.

var htmltrimmed = $.trim(contentform);  var htmlcontent = $.parsehtml(htmltrimmed); console.log(htmltrimmed); $('#currentform').html(htmltrimmed); 

but when check console of check actual div, there plain string inserted.:

string in html

you see gets treated string. don't understand why it's acting this.

edit:

this contentform value, i've cut of off, because string long, actual value valid html string!:

&lt;form class=&quot;form-horizontal&quot; &gt;&lt;fieldset&gt;&lt;!-- form name --&gt;&lt;legend&gt;dmn sgt&lt;/legend&gt;&lt;!-- multiple radios --&gt;&lt;div class=&quot;control-group&quot;&gt;  &lt;label class=&quot;control-label&quot; for=&quot;multipleradios-0&quot;&gt;grund der messebesuch&lt;/label&gt;  &lt;div class=&quot;controls&quot;&gt;    &lt;label class=&quot;radio&quot; for=&quot;multipleradios-0-0&quot;&gt;      &lt;input type=&quot;radio&quot; name=&quot;multipleradios-0&quot; id=&quot;multipleradios-0-0&quot; value=&quot;konkretes interesse produkt&quot; checked=&quot;checked&quot;&gt; 

use $.parsehtml example

see example: http://jsfiddle.net/kevalbhatt18/lny2m0kc/1/

var t = $.parsehtml('&lt;form class=&quot;form-horizontal&quot; &gt;&lt;fieldset&gt;&lt;!-- form name --&gt;&lt;legend&gt;dmn sgt&lt;/legend&gt;&lt;!-- multiple radios --&gt;&lt;div class=&quot;control-group&quot;&gt;  &lt;label class=&quot;control-label&quot; for=&quot;multipleradios-0&quot;&gt;grund der messebesuch&lt;/label&gt;  &lt;div class=&quot;controls&quot;&gt;    &lt;label class=&quot;radio&quot; for=&quot;multipleradios-0-0&quot;&gt;      &lt;input type=&quot;radio&quot; name=&quot;multipleradios-0&quot; id=&quot;multipleradios-0-0&quot; value=&quot;konkretes interesse produkt&quot; checked=&quot;checked&quot;&gt;') console.log(t);  $('#test').html(t[0].data) 


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -