Why isn't this simple bit of jQuery getJSON working in IE8?

后端 未结 5 708
时光说笑
时光说笑 2021-01-03 03:03

I\'ve got a very standard AJAX request:

$.getJSON(\'/products/findmatching/38647.json\', {}, function(JsonData){
  var tableHtml = \'\';
  var x;

  for (x i         


        
5条回答
  •  粉色の甜心
    2021-01-03 03:22

    Ok I figured it out. Someone suggested trying a non-minified version of jQuery. I did this and stepped through the IE8s Javascript debugger. At a certain point, the following error came up:

    Could not complete the operation due to error c00ce56e.
    

    A little Googling found that it was the charset declaration I've set for my JSON data. In PHP, this was done with:

    header ( 'Content-Type: text/javascript; charset=utf8' );
    

    It turns out that IE is very particular about the charset reference ( http://forums.asp.net/t/1345268.aspx#2732852 ), so I changed it to:

    header ( 'Content-Type: text/javascript; charset=UTF-8' );
    

    And hey-presto, it works like a charm. Thanks for your help guys, you pointed me in the right direction again!

提交回复
热议问题