why isn't it working? The ok () method doesn't give me the correct object. But when I use buttons to activate the methods one by one then it works. Even if I write "await" in front of the getdata () method. It doesn't work.
<script>
var javaobj = new Object() ;
function ok(){
console.log(javaobj);
}
function getdata()
{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (xhttp.readyState==4 && xhttp.status==200) {
javaobj=JSON.parse(xhttp.response);
}
}
xhttp.open("GET", "test.json", true);
xhttp.send();
}
getdata()
ok()
</script>
Aucun commentaire:
Enregistrer un commentaire