I am just trying to get the data returned (from a php script, the script is working fine)
$.post(
"http://labs.*********.com/inc/ajax/till_status.php",
{
id:$("#potentialID").val()
}
).done( function (data) {
currentTillStatus = data;
});
And I want it to be placed into the variabled called currentTillStatus.
Where am I going wrong?
Okay, full code is here:
function checkStatus() {
var currentTillStatus = null;
$.post(
"http://labs.*****.com/inc/ajax/till_status.php",
{
id:$("#potentialID").val()
}).done(function (data) {
currentTillStatus = data;
});
console.log("Till Status: " + currentTillStatus);
}
$(document).ready(function () {
checkStatus();
setInterval(checkStatus,1000);
});
And result:
Till Status: null
$.get, but your code is using$.post. What is your PHP script expecting?console.log("Till Status: " + currentTillStatus);but I getTill Status: null