[eluser]Pascal Kriete[/eluser]
I'm having a hard time reproducing this error. Are you using a js library? If yes, which one?
Here's my attempt using jquery. It works perfectly.
Controller
Code:
function ajax()
{
echo "<script>alert('hi');</script>";
}
function ajax2()
{
$d = <<<HTML
<textarea name="site_pal_code" id="site_pal_code" cols="55" rows="10">
<script>alert("test");</script>
</textarea>;
HTML;
echo $d;
}
View
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
<!-- Meta Tags -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="/js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
init = function() {
$.ajax({
url: "<?= site_url('test/ajax'); ?>",
success: function(html) {
$("#testbox").get(0).value = html;
}
});
$.ajax({
url: "<?= site_url('test/ajax2'); ?>",
success: function(html) {
$("#testdiv").html(html);
}
});
}
$(document).ready(init);
</script>
</head>
<body>
<form action="test_submit" method="get" accept-charset="utf-8">
<textarea name="Name" id="testbox" rows="8" cols="40"></textarea>
<p><input type="submit" value="Continue →"></p>
</form>
<div id="testdiv"></div>
</body>
</html>