I'm getting a file from my server with the file_get_contents command. On the fly, when I use the inspect element of chrome, I can see the content of the file, which I assign in a jQuery string a few lines below. When I try to alert the variable I see nothing, in chrome's debugging I see the error Uncaught SyntaxError: Unexpected token < The file has an xml format like this,
<test1> <test1.1>blabla </test1.1> </test1>
I tried to remove the bracket < and replace it with "& l t ;" but nothing happened
$file = './xxx/xxx/test.xml';
if (file_get_contents($file) != false) {
$str = file_get_contents($file);
}
jQuery
$getvals = <?php echo $str ;?>;
alert($getvals);