Gary Ryan Gary Ryan - 1 month ago 7
Ajax Question

Line breaks won't display in textarea in IE

Using jQuery's

method I'm loading text into a textarea. Works fine in Chrome & FF. As always, IE just has to be different and won't display the line breaks.

I've tried
with no luck.

Any ideas?

My code:


The data.php simply queries a MySql database and prints the results.

Answer Source

They're compatibility problems with IE when using innerHTML(). As Jquery's .html() and .load() methods both use innerHTML(), they by extension can result in some issues. One solution is to use .text() instead. If you want to load text into a <textarea> using AJAX and Jquery you need to do something like this: