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 !

Answers


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.


Need Your Help

How do I pause everything running on a webpage?

javascript google-chrome

I have a piece of JavaScript code running in browser and I want to pause it to see what values are in the console.

Change custom post-type rewrite

wordpress .htaccess mod-rewrite

I have a custom theme that uses custom post types for my portfolio e.g. mysite.com/portfolio/. Once I click on a specific portfolio item the URL changes to mysite.com/portfolio-type/name/

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.