Why is jQuery value rounded up?

Using ajax, I request the authentication identifier as follows: enter image description here


This is not true because real HTTP Transfer is like this:

enter image description here

(By the way: response-type - "application / json; charset = UTF-8")

I see a clash between

-1369082024195183657 and -1369082024195183600 

How to prevent rounding or is it a mistake?

+5
source share
2 answers

Yes, this is a mistake. Server returns illegal JSON! Generated report: https://github.com/FasterXML/jackson-core/issues/291

0
source

jQuery is trying to parse the HTTP response as a whole based on the JSON content type.

 > JSON.parse("-1369082024195183657") -1369082024195183600 

You can override it by telling jQuery that you are expecting a string by setting the dataType property in the $.ajax configuration:

 $.ajax({ dataType : "text", url : "rest/Registration", success : function(data){ // data should be "-1369082024195183657" } }) 

I think you do not need to do any arithmetic with the authentication identifier token, so you can just save it as a string.

+3
source

All Articles