简体   繁体   中英

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 !

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM