internet explorer - jQuery and JSON vs IE - SCRIPT5007: Unable to get value of the property -


i'm struggling script working. it's simple ajax call retrieve data php returns json code.

function refreshwindows(){ if(ajaxpull && 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 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) );     } }); 

}

the error in internet explorer is:

script5007: unable value of property 'updates': object null or undefined

everything works fine in firefox , google chrome.

initially code made using .get suggested switching .ajax - well, didn't help. tried using .done(function(data){ didn't work either. tried sending of data in url opposite data property, worked fine in ff, ie still popped same error. tried adding different headers php, example header('content-type: application/json'); didn't change anything. run out of ideas / possible solutions fine on stackoverflow, appreciated.

in ie went developer tools, network tab , tried see if works - yes, request being sent correctly data, , response receive correct json, in firefox:

{"updates":{"1":"","2":"","3":"","5":"","6":"","7":"","8":""},"time":{"from":"1367489761","to":"1367489761"}} 

which gets me confused, cause i'd have thought undefined error might happen because not being sent in ie whatever reason, clearly: it's not case. json back. ie unknown reason still thinks data undefined.

ok, found solution finally. basically:

  • remove headers sent php script. especially: content-type headers. (luckily - seems sessions still can used)
  • use }).done(function ( data ) { instead of success: function (data) {

and that's all. started work. it's weird. seems shotgun tactic (randomly changing bits of code till works) valid way of solving problems. hehehe


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -