私はjQueryが初めてで、JSONデータを関数に正しく渡しているかどうか疑問に思っていました.
私が何か間違ったことを言っている場合、または提供する必要がある情報が他にある場合。お気軽にお知らせください!助けてくれてありがとう!とても有難い!
Chrome デベロッパー ツールによると。次のエラーが表示されます。
Uncaught TypeError: Cannot read property 'GhStatus' of undefined
これが私の機能です:
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");
}
これは私のJSONデータです:
{
"GhStatus": 0,
"CsStatus": 0
}