I am trying to populate textarea with data from a TXT file. I tried to use answers to similar questions, but I can not find the one that works. In the head of the file, I have this to import the library that is used with jQuery:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Text declaration declaration:
<textarea id="fillText" cols="40" rows="5"></textarea>
This is the script tag that I have right after the textarea declaration:
<script>
var fileName = '<?php echo $fileN;?>.txt';
jQuery.get(fileName, function(data) {
alert(data);
$('fillText').html(data.replace('n',''));
});
</script>
I also tried using this:
$(".fillText").load(fileName);
But for some reason this does not work.
source
share