I have a JSON-Object which includes following example entry:
description":"<div>- diversen Diskutanten- Moderiert vom gro\u00dfartigen PreibischDebatte, Gesprochenes, Kontroverses<div class="btn-group"><a class"btn" href=""><i class="icon-map-marker"><\/i><\/a><a class"btn" href=""><i class="icon-map-marker"><\/i><\/a><\/div><\/div>"
Now i am trying to add this html to another element in my code with:
$('#desc_text').empty();
$('#desc_text').html(event.description);
$('#description').modal('show');
The problem is that the html is not parsed as html, which I thought jquery .html()
would do. I also tried with append()
, but no change too.
Does anyone know how to parse this as html?
EDIT 2: The whole workflow, because it seems little confusing:
first I do:
$events = json_encode($func->getAllDates());
the function does:
public function getAllDates() {
$this->db->query('SELECT * FROM dates ORDER BY start');
$result = $this->db->mysql_fetch_all();
for($i = 0; $i < count($result); $i++) {
$result[$i]['description'] = html_entity_decode(utf8_encode($result[$i]['description']));
}
print_r($result);
return $result;
}
Output of $result in function:
[6] => Array
(
[id] => 17
[title] => Sabotage Debatte: Politik im Keller
[start] => 2012-11-29 00:00:00
[end] => 2012-11-29 00:00:00
[allDay] => 1
[url] =>
[description] => <div>- diversen Diskutanten- Moderiert vom großartigen PreibischDebatte, Gesprochenes, Kontroverses<div class="btn-group"><a class"btn" href=""><i class="icon-map-marker"></i></a><a class"btn" href=""><i class="icon-map-marker"></i></a></div></div>
)
EDIT:
As in comments said: The quoting seems the answer, but I don't quote by myself and just use php-functions. Maybe the way I do is the wrong way.
I got something like this from my database:
&lt;div&gt;- diversen Diskutanten- Moderiert vom großartigen PreibischDebatte, Gesprochenes, Kontroverses&lt;div class=&quot;btn-group&quot;&gt;&lt;a class&quot;btn&quot; href=&quot;&quot;&gt;&lt;i class=&quot;icon-map-marker&quot;&gt;&lt;/i&gt;&lt;/a&gt;&lt;a class&quot;btn&quot; href=&quot;&quot;&gt;&lt;i class=&quot;icon-map-marker&quot;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
then I use
html_entity_decode(utf8_encode($result[$i]['description']));
to turn it back and then i use json_encode to put it in json-format. Shouldn't do any of this functions a correct quoting?
I hope you get to the workflow...