$ .ajax 200 OK,parseerror,Internet Explorer 7,8,9,10上的无效字符

时间:2013-12-27 11:20:42

标签: javascript json internet-explorer parse-error invalid-characters

这一大块代码适用于Chrome,FF,但它无法在Internet Explorer上运行! 它只是一个简单的JSON文件调用,获取数据,并显示到HTML网页。看看下面:

$.ajax({
              type: "GET",
              url: "shop.json",
              cache: false,
              data: "{}",
              success: function(jd) {
                $.each(jd.lots, function(i,f){
                  if(f.shop.category != "PARKING")
                  {
                    if(jQuery.inArray(f.shop.category, categoryArray) == -1) //not in array
                    {
                      categoryArray.push(f.shop.category);
                     $('#tenant-list').append('<table width="100%" class="tenantList" id="' +jQuery.inArray(f.shop.category, categoryArray) + '"><th class="title" style="background-color: orange;" colspan="3">'+f.shop.category+'</th>');
                      $('.categoryList').append('<tr><td><a class="categoryListAnchor" style="color: #666666;text-decoration: none;" href="#'+jQuery.inArray(f.shop.category, categoryArray)+'">'+f.shop.category+'</td></tr>');
                    }
                    $('#'+jQuery.inArray(f.shop.category, categoryArray)).append('<tr><td class="shopName" width="500px;">' + f.shop.name + '</td><td><img src="images/'+f.zone+'.jpg"></td><td>' +f.floor + '</td></tr></table>');

               };
                });

                        $("#tenant-list").jSort({
                              sort_by: 'th.title',
                              item: 'table',
                              order: 'asc'
                            });


                        $(".tenantList").jSort({
                              sort_by: 'td.shopName',
                              item: 'tr',
                              order: 'asc'
                           });

                        $(".categoryList").jSort({
                              sort_by: 'td',
                              item: 'tr',
                              order: 'asc'
                           });
                        $("#instruction").show();
                        $("#ajaxLoading").hide();

              },
              error: function (request, status, error) { 
                        alert(request.status + ", " + status + ", " + error); 
                      }
                      });

shop.json它本地存储的1.2mb json文件在jsonlint中完全验证,有0个错误。所以我想不会有任何交叉起源问题。 但是当我在IE上测试我的脚本时,执行了错误功能,并给我一个警告:

  200, parseerror, SyntaxError: Invalid Character

IE开发者控制台中的ResponseHeader显示了我的JSON文件的完整内容,看起来似乎是200 OK。

请帮助我。 p / s:上面的代码,我在此之前添加了“dataType: json”和“contentType: "application/json; charset=utf-8”,也是同样的错误。

让我知道任何人都需要更多信息。

1 个答案:

答案 0 :(得分:0)

可能为时已晚,但请查看&#34; shop.json&#34;你指的文件。 JSON对象中的任何属性都不应该是未定义的&#39;值

如果您尝试解析的JSON对象中的某个属性未定义&#39; IE会给出错误。