jQuery $.get response is different when Infinity is in the response

I have an API that returns two numbers as a response. For example if I call this

$.get('/api/get_limit/').always(function(data) { console.log(data.responseText); });

I expect to see something like this in the console

Object {absolute_limit: 389, concurrent_limit: 999}

Which is what I get, except when one of these numbers is Infinity. In that case when I make the same request, the console will show

Object {readyState: 4, responseText: "{"absolute_limit":Infinity,"concurrent_limit":999.0}", status: 200, statusText: "OK"}

I checked and API is working as expected in both cases.

My question is why this happens and is there a way I can fix this without substituting Infinity with something like -1?

EDIT:

Django code for generating API with the help of Django Rest Framework

class QueriesLimit(APIView):
    def get(self, request, format=None):
        limit = request.user.concurrency_limit()
        abs_limit = request.user.available_queries()
        return Response({'concurrent_limit': limit, 'absolute_limit': abs_limit})

Answers


cause

{
    "absolute_limit": Infinity,
                      ^^^^^^^^
    "concurrent_limit": 999.0
}

is not a json object


Need Your Help

TSQL: NOCHECK Foreign Key inside CREATE TABLE

sql-server tsql

I want to add a foreign key constraint inline with my CREATE TABLE statement. However, I also want to include the NOCHECK attribute. Can this be done in one pass inside the CREATE TABLE statement? I

Write a File into the App Bundle

iphone ios xcode nsbundle

I have a Webservice to download some News and write them into a plist-file somewhere in NSLibraryDirectory, thats fine. But if the user has no Internet connection or the webservice is offline or

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.