The answer witch had been linked is 9 years old and i don't think that this is uptodate.
I try to send a var from a PHP scrit to a js scrip with Ajax but i am not sure that this is working and so i have tried to have it in the console log but i get this error :
My php script is as following :
<?php
$var = "Mountain";
echo json_encode($var);
echo $var;
?>
<div id="Window">
<script
src="TestAjax9.js">
</script>
and the script TestAjax9.js is as following :
var requete = new XMLHttpRequest();
requete.onload = function() {
//La variable à passer est alors contenue dans l'objet response et l'attribut responseText.
var variableARecuperee = this.responseText;
};
requete.open("get", "line_chart V14.php", false); //True pour que l'exécution du script continue pendant le chargement, false pour attendre.
requete.send();
console.log("AU",variableARecuperee);