Strange Parsing JSON Behavior In IE8

I have strange behavior in IE8 that I cannot explain the execution of the following JavaScript function:

function getStatus() {
    var action = "/Device/Status";

    $.getJSON(action, function (data) {
        $.each(data, function (i, e) {
            $('#btnEmergency' + e.BoreId).val(e.InEmergency ? "On" : "Off");
        });
    });
}

When Fiddler is loaded, I verify that the following JSON results are returned (note that InEmergency is false for all holes):

[{"BoreId":1,"InEmergency":false},{"BoreId":2,"InEmergency":false},{"BoreId":3,"InEmergency":false},{"BoreId":4,"InEmergency":false},{"BoreId":5,"InEmergency":false},{"BoreId":6,"InEmergency":false}]

Strange, e.InEmergency returns true for line 1 (only in IE8 (I have not tested other versions of IE, I mean that it works correctly in Chrome, Firefox and Safari)), as a result, the button value is set to "On" . Am I missing something that should be obvious?

+3
source share
2 answers

Internet Explorer (). , XMLHTTPRequest, .

- , , , , , . - :

function getStatus() {
    var action = "/Device/Status";

    $.getJSON(action + '?_=' + (new Date()).getTime(), function (data) {
        $.each(data, function (i, e) {
            $('#btnEmergency' + e.BoreId).val(e.InEmergency ? "On" : "Off");
        });
    });
}

, () , jQuery cache: false $.ajax (b), URL-, &_=.

+1

, dom eval() , . , . json , abd, . , IE.

+1

Source: https://habr.com/ru/post/1790234/


All Articles