Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery and JSON vs IE - SCRIPT5007: Unable to get value of the property
    primarykey
    data
    text
    <p>I'm struggling to get this script working. It's basically a simple ajax call to retrieve data from a php which returns a JSON code.</p> <pre class="lang-js prettyprint-override"><code>function refreshWindows(){ if(AjaxPull &amp;&amp; AjaxPull.readystate != 4){ AjaxPull.abort(); } AjaxPull = $.ajax({ type: 'POST', url: $path, data: { ajax: true, mode: 'update', to: Math.round(currentDate.getTime() / 1000), from: Math.round(previousDate.getTime() / 1000) }, dataType: "json", success: function (data) { alert(data); //that's for debug $replies = data.Updates; $.each($replies ,function(group,value) { if (value!=''){ $("#group"+group+" .content").append(value); $("#group"+group+" .content").stop().animate({ scrollTop: $("#group"+group+" .content")[0].scrollHeight }, 800); if (!$("#group"+group+" .Window").is(':visible')) { $("#group"+group+" .BottomBox").fadeTo('fast', 0.5).fadeTo('fast', 1.0); } } }); previousDate = currentDate; currentDate = new Date(); timeController.push( setTimeout(function(){refreshChatWindows();}, 500) ); } }); </code></pre> <p>}</p> <p>The error I get in Internet Explorer is:</p> <blockquote> <p>SCRIPT5007: Unable to get value of the property 'Updates': object is null or undefined</p> </blockquote> <p>Everything works fine in Firefox and Google Chrome.</p> <p>Initially my code was made using <a href="http://api.jquery.com/jQuery.get/">.get</a> but someone suggested switching to the <a href="http://api.jquery.com/jQuery.ajax/">.ajax</a> - well, it didn't help. I tried using <kbd>.done(function(data){</kbd> but it didn't work either. I also tried sending all of the data in my URL opposite to the <kbd>data</kbd> property, it worked fine in FF, but IE still popped the same error. Finally I tried adding different headers to the PHP, like for example <kbd>header('Content-Type: application/json');</kbd> but it didn't change anything. I run out of ideas / possible solutions I could fine on stackoverflow, so any help would be appreciated.</p> <p>In IE I went to Developer Tools, network tab and tried to see if everything works - yes, the request is being sent correctly with all the data, and a response I receive is correct JSON, just as it is in Firefox:</p> <pre><code>{"Updates":{"1":"","2":"","3":"","5":"","6":"","7":"","8":""},"time":{"from":"1367489761","to":"1367489761"}} </code></pre> <p>which gets me really confused, cause I'd have thought that Undefined error might happen only because something is not being sent back in IE for whatever reason, but clearly: It's not the case. I get my JSON back. Only IE for some unknown reason still thinks that data is undefined.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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