I'm trying to retrieve content from sites/2.php
(the content is a plain text link) and put it into an <a href="#" id="tpbx">Test</a>
, instead of the #
. I edited the second option in this answer, but it doesn't work. I also tried setting the header of 2.php
to UTF-8 by using this line of code:
header('Content-Type: text/html; charset=utf-8');
But that didn't help.
My code is:
<script>
$(function() {
$.get('sites/2.php', function(data) {
$('#tpb').attr('href', $(data).text());
});
});
</script>
And the content of 2.php is generated by another (in this case not relevant) script, and could look like this:
<?php
header('Content-Type: text/html; charset=utf-8');
?>
something:?something
Does anyone know why this is not working?