schglurps
schglurps

Reputation: 1387

Unable to retrieve particular JSON objects using jQuery

I try to retrieve a JSON object with jQuery from a server. Some properties of this object are arrays. When these arrays are not empty, I'm able to process my object. But when I retrieve a JSON like this one :

{"Id":144,"Identifier":"4000011","ContractId":115,"ContractName":"Test4","Meters":[],"Scans":[]}

where "Meters" and "Scans" are empty, jQuery raises an error... I query my server with this code :

    $("#test").click(function () {

        $.ajax({
            type: "GET",
            url: "/Gateway/GetDetails/144",
            data: {},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data, textStatus, jqXHR) {

               ...

            },
            error: function (jqXHR, textStatus, errorThrown) { 
               ...
            }
    });

In the error handler, I can see my JSON object in the responseText property of the parameter "jqXHR". Did you encounter this problem ?

Thanks in advance !

Upvotes: 1

Views: 238

Answers (2)

schglurps
schglurps

Reputation: 1387

I answer my own question... First I tested only with Internet Explorer 9; with an other browser, all worked as expected. After I cleared the Internet Explorer cache, the problem disappeared.

Upvotes: 0

JonnyReeves
JonnyReeves

Reputation: 6209

The JSON you've supplied is valid (as confirmed by the JSON Lint tool); is it possible that the Server you are querying is returning an HTTP Error Status Code, or that an internal error is happening on the server side. You can confirm this by using a debugging proxy like Firebug, Chrome Developer tools.

Upvotes: 1

Related Questions