Issue with jQuery data() treating string as number

This isn't a case of "long int" really, the number you're getting is the closest available representation as a floating-point number.

Anyway, you want the value as a string. Quote the jQuery docs for .data (emphasis mine):

Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null) otherwise it is left as a string. To retrieve the value's attribute as a string without any attempt to convert it, use the attr() method.


There's no such thing as a "long integer" in JavaScript. All numbers are 64-bit floating point. Your number there cannot be represented exactly in IEEE-794 floating point representation.

The only way to "fix" this is to make the number into a string in a domain that can cope with big integer values.


try typecasting it to string:

id: '' + $(this).data('id').toString();