Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON.stringify not working in IE10
    primarykey
    data
    text
    <p>I am trying to parse some form data to produce JSON data to send in an ajax request. The following HTML is an oversimplified version of my code. I'm using APS.Net MVC4 and my rendered view produces the following HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;Index&lt;/title&gt; &lt;link href="/Content/site.css" rel="stylesheet"/&gt; &lt;script src="/Scripts/modernizr-2.6.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="test-class" data-my-attribute="1"&gt;&lt;/div&gt; &lt;div class="test-class" data-my-attribute="2"&gt;&lt;/div&gt; &lt;div class="test-class" data-my-attribute="3"&gt;&lt;/div&gt; &lt;script src="/Scripts/jquery-1.8.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { jsonObj = []; $(".test-class").each(function () { var myAttribute = $(this).data('my-attribute'); item = {} item["MyAttribute"] = myAttribute; jsonObj.push(item); }); var data = { SomeOtherData: 1234, MyAttribs: jsonObj }; console.log(JSON.stringify(data)); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In Chrome the output in the console is output as expected ...</p> <pre><code>{ "SomeOtherData": 1234, "MyAttribs": [{ "MyAttribute": 1 }, { "MyAttribute": 2 }, { "MyAttribute": 3 }] } </code></pre> <p>... but in IE the objects come out as null ...</p> <pre><code>{ "SomeOtherData": 1234, "MyAttribs": [null, null, null] } </code></pre> <p>I've had a look around and found some other questions that recommend checking that the page has <code>&lt;!DOCTYPE html&gt;</code> in it (which it does) and that doesn't seem to have any effect. I've also read that this should work in from IE8 onward so not sure what's happening.</p> <ol> <li>Does anyone know why the objects are appearing as nulls in IE?</li> <li>What is the best cross-browser solution to this?</li> </ol> <p>Thanks, Gavin</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload