Jorge
Jorge

Reputation: 18237

appended html to the dom doesn't respect the charset

I have some HTML rendered by ajax, which works perfectly fine using the char-set utf-8 nevertheless some content it's appended to the dom by a JavaScript function using jquery. The problem is, the HTML rendered doesn't have the correct char-set.

Here's the example of the content added by JavaScript

var html = '<div class="right-item-container"><a href="#"><span style="font-size:24px;" class="item-friend-name">Mamá</span></a><br/><a href="#"><span class="clubName-container">school</span></a></div>';

$('.profile-container').empty().css({ 'padding-top' : '0'}).html(html);

It renders like this:

html render

enter image description here

Upvotes: 3

Views: 69

Answers (1)

mark_huffington
mark_huffington

Reputation: 464

This works fine in a fiddle.

http://jsfiddle.net/HjCpp/

var html = '<div class="right-item-container"><a href="#"><span style="font-size:24px;" class="item-friend-name">Mamá</span></a><br/><a href="#"><span class="clubName-container">school</span></a></div>';


$('#test').html(html);

So it must be the way your original content is encoded.

Upvotes: 3

Related Questions