On some of my PHP pages I like to load data from another place, and populate an input or textarea.
I run into problems when there's html tags involved. (apostrophes too) I notice in FF that the html simply isn't too good at being passed around with javascript in general. (error console)
So I'm looking for help in how to HONE this, if possible.
Main Page:
<textarea name="templatetext" id="templatetext"></textarea>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
/* calls page2.php */
$.ajax({data:"formId=loadtemplatetext",
success:function(response){
eval(response);
}
});
return false;
});
});
</script>
Page2.php
<?php
$templatetext = '<p>This is a test email<br /><br /><br /></p>
<p><span style="color: #808080; font-size: 12px; font-family: Tahoma,sans-serif;"><strong>Some Text here with an apostophe or image: <br /><img title="Test Img" src="http://somefakeurl.com/img/somefakeimg.gif" alt="test img" width="112" height="59" />';
die('$("#templatetext").val("'.addslashes($templatetext).'");');
?>
This works great with regular/plain text.
Am I able to clean this up for populating the value inside a <textarea>?
die()ing when you could just beechoing?echo $var; exit;if you want to quitdie()is javascript, it needs to be inside of script tags.