Reputation: 814
When populating a textarea with special characters from a jQuery GET request, the special characters display as html codes. Eg. é rather than é.
The PHP file is outputting the text using htmlentities. Eg. echo htmlentities($text);
The pertinent part of jQuery request is here:
success:function(data){
$('textarea').val(data);
}
Upvotes: 0
Views: 1572
Reputation: 150253
Use Jquery
html
function instead of val
:
success:function(data){
$('textarea').html(data);
}
val
will assign the "escaped" value, you want the HTML representation - html
.
Watch this JSFiddle.
Upvotes: 1
Reputation: 5575
You can try this
$("button").click(function(){
$("#test").val($("<div>").html(data).text());
});
Upvotes: 0
Reputation: 3829
success:function(data){
$('textarea').html(data);
}
Does that work? Can't think, off the top of my head, but it should.
Upvotes: 2