0

Related (but not a duplicate): Is JSON.stringify() supported by IE 8?

Also related (but a different IE version): JSON object undefined in Internet Explorer 8

I was working with QA to test a feature; the feature works perfectly on my system, but on his system he's getting a 'JSON is undefined` exception in his Developer console:

enter image description here

I, however, get no exceptions at all in mine.

Both of us are running the same code in Internet Explorer 11 in Compatibility View (although we're using slightly different versions of IE11, he's using 11.0.9600.18617 and I'm using 11.953.14393.0).

"About" dialog from his computer:

enter image description here

"About" dialog from mine:

enter image description here

And here's the relevant code:

function GetNewList() {
  jQuery.ajax({
    url: "MyAspxPage.aspx/GetServiceInformation",
    type: 'post',
    // It apparently complains about this line for him
    data: JSON.stringify({
      "scheduleDate": jQuery('#ATextBox').val()
    }),
    dataType: 'json',
    processData: false,
    contentType: 'application/json; charset=utf-8',
    // TODO: Error?
    complete: function(response, status) {
      if (status == 'success') {
        // Presumably, this is a problem too
        var jsonParsed = JSON.parse(response.responseText)

        // Get my dropdown menu
        var dropdown = document.getElementById('MyDropDown')

        // Remove all of the existing options
        var length = dropdown.options.length
        for (i = 0; i < length; i++) {
          dropdown.remove(0)
        }

        // Add all of the current objects
        jsonParsed.d.each(function(element) {
          var option = document.createElement('option')
          option.value = element.ServiceTypeId;
          option.text = element.ServiceTypeName;

          dropdown.add(option)
        })

        // Re-add --Select--, but only if there are other options. Otherwise leave it empty.
        if (jsonParsed.d.length > 0) {
          var option = document.createElement('option')
          option.value = 0
          option.text = '--Select--'
          dropdown.add(option)

          dropdown.disabled = false;
        } else {
          dropdown.disabled = true
        }
      }
    }
  })
}

On a related note, I would like to just replace this completely with an UpdatePanel but I was having trouble getting it working.

Does anyone know what could be causing this, and how I might fix it?

2
  • Just curious so you did try the solutions mentioned? It does sound like your document mode is off but it also seems strange that it would work for one and not the other. I assume its not possible to see if upgrading the version of IE11 on QA's machine would work? Commented Apr 7, 2017 at 16:56
  • My guess is the webpage has headers on it t render in an old IE mode. Commented Apr 7, 2017 at 17:27

1 Answer 1

1

You may want to include a JSON polyfill in your app for older versions of IE. I had one running in a app that runs in IE 5 mode. Also convince your team to upgrade from that old version of I.E

Here is one for json 3 http://bestiejs.github.com/json3

You can read about that here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.