javascriptjsoninternet-explorerjquery-2.0

JSON is not declared error in IE8


I have problem figuring out how to get rid of the series of errors I receive while running my application in IE8 and earlier. First of the errors shows in jquery.mi.js script: "JSON not declared". Obviously since JSON is not declared in the first place, then other errors like "object not specified" or "$ not declared" pop up. IE9 and 10 run the application flawlessly as well as all other browsers.

The jquery.min.js script is loaded first as you can see in the following index.html header:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="NAPSitesHead">
<title>Site Search</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js" type="text/javascript"></script> 
<script src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false" type="text/javascript"></script>
<script src="js/geo.js?id=1" type="text/javascript"></script>
<script src="js/index.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen,print" href="CSS/CommonSS.css"/> 
</head>

I would like to note that I saw many posts and discussions about similar problems but none of their solutions/suggestions seem to apply in my case.

Thanks a lot for your ideas, Jacek

Edited after changing jquery version to 1.10.1:

Here is the ajax call that causes error now:

function KenMapLoad(KenID, AddrPart, SearchTxt, RBSearchType)
{
$.ajax({
    type: "POST",
    url: "WebSVC.asmx/KenMapSites",
    data: "{KenID:'" + KenID + "', AddrPart:'" + AddrPart + "', SearchTxt:'" + SearchTxt + "', RBSearchType:'" + RBSearchType + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data)
    {
        var locs = [];
        //line below causes "JSON not defined" error
        var objSites = JSON.parse(data.d);

        $.each(objSites, function (i, item)
        {
            locs.push([item.LocNmKanji, item.Address, item.TelNo, item.MachServ, item.Access, item.Latitude, item.Longitude]);
        });
        //Puting extracted locations on the map:
        PutMarkersOnMap(locs, 0);
    },
    error: function (error)
    {
        alert('県リスト読み込みエラー: ' + error.status);
    }
});

};


Solution

  • Jquery 2.0 is not supporting IE6/7/8

    Change Jquery version and then try.

    documentation