What could be causing the undefined value of x at line 11, even though it was defined in line 9?
<script>
var x;
$.ajax({
dataType: "json",
url: myurl,
success: function(data){
console.log(data);
x = data;
document.write(x);
}
});
document.write(x);
</script>