The number after the decimal point of the data requested by jsonp is gone.

in a project, I tried to obtain the data of Douban API through jsonp, but found that the score changed from 7.1 to 6.

related codes

$(document).ready(function(){
    if($("-sharpdouban_score").length > 0) {
        var name = "";
        $.ajax({
            type: "get",
            dataType: "jsonp",
            jsonp:"callback",
            timeout: 5000,
            url: "http://api.douban.com/v2/movie/search?q="+ name +"&count=1",
            error: function(){
                alert("");
            },
            success:function(data){
                if(data.subjects[0].rating.average!=0){
                    $("-sharpdouban_score").text(data.subjects[0].rating.average)
                }
            }
        })
    }
});

part of the data obtained by jsonp:

clipboard.png

json

clipboard.png

it seems to be compressed. How can I not compress this data?

Oct.20,2021

if you want to keep the decimal point of the returned data, you can use toFixed (digits)

   
I have exactly the same code here. If you don't reproduce your problem, you can check whether it is the jq version

.
Menu