I'm new to jQuery and I was wondering if I am passing my JSON data correctly into the function.
If I am saying something incorrectly or there is more information I need to provide. Please feel free to let me know! Thank you for all the help! Much appreciated!
According to Chrome Developer Tools. I get this error:
Uncaught TypeError: Cannot read property 'GhStatus' of undefined
Here is my function:
function MachineOffChecker() {
var url = '@Html.Raw(Url.Action("index","GhCs"))';
$.get(url, window.setInterval(
function(data) {
if (data.GhStatus == 0) {
$('#GhCsStatus_CS').buttonMarkup({ icon: 'myapp-cs' });
alert('crash');
}
else {
$('#GhCsStatus_GH').buttonMarkup({ icon: 'myapp-gh' });
alert('running');
}
if (data.CsStatus == 0) {
$('#GhCsStatus_CS').buttonMarkup({ icon: 'myapp-cs' });
alert('crash');
}
else {
$('#GhCsStatus_GH').buttonMarkup({ icon: 'myapp-gh' });
alert('running');
}
}, 2000), "json");
}
This is my JSON data:
{
"GhStatus": 0,
"CsStatus": 0
}