Part of my code
var tablo = {
tablo_id: 0,
retrivedData: 1234,
getData: function() {
var xhr;
var data = "aranan=" + document.getElementById('aranan').value;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
this.retrivedData = JSON.parse(xhr.responseText);
console.log(this.retrivedData); //first
}
}
xhr.open("POST", "listele.php", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(data);
},
setData: function() {
console.log(this.retrivedData); //Second
}
}
}
function u() {
tablo.getData();
tablo.setData();
}
When I run function u() first console.log work but seconde one does not work ,second only returns 1234 . I use function u() in button onclick event