JS number is too long cause the front and back number is not the same (really JS a big pit)

Source: Internet
Author: User

function Send () {        var users=[1000000013810001001];        var data={                users:users,                flag:true        };        var address= "192.168.30.237:10101";        Alert (json.stringify (data));        $.ajax ({              URL: "<%=request.getcontextpath ()%>/api/commandkey/chat_block",              type: "Post",              DataType: "JSON",              data:{"params": json.stringify (data), "Address": Address},              success:function (data) {                  Alert (json.stringify (data));              }        )

Code as above

Backstage I use directly

    Jsonobject Jo = Jsonobject.fromobject (jsonstr);     Userstatusvo vo = null;      Vo = (USERSTATUSVO) Jo.tobean (Jo, Userstatusvo.class);

Backstage I directly converted to Java objects with JSON characters, and later found that I can not send users to prohibit the message

I also to why serialization problem, tangled for a long time, consumed me half a day

The back compares the numbers passed over and compares them carefully.

Browser start value: 1000000013810001001<pre name= "code" class= "JavaScript" ><pre name= "code" class= "JavaScript" > The browser passed the value: 100000001381000100<span style= "color: #FF0000;" ><span style= "Background-color:rgb (255, 0, 0); >0</span></span>


Fuck, I was so angry.

JS Object uses Json.stringify (); method numbers are lost by a 1

Too dog blood, I hope you pay special attention in the future

Finally, I'll just change it to a string and it's OK.

<pre name= "Code" class= "JavaScript" >var users=["1000000013810001001"]


JS number is too long cause the front and back number is not the same (really JS a big pit)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.