When attempting to send the id
and quantity
as integers, I encountered an issue where the id
was being posted as a string instead. Despite defining them as integers in my code, this problem persisted.
I know I must be missing something simple here, but I just can't seem to figure it out. How can I ensure that both id
and quantity
are sent as integers? The code snippet causing the problem is outlined below:
var id = parseInt(identifier, 20);
var quantity = parseInt(amount, 10);
var updates = {};
updates[id] = quantity;
$.post('/cart/update.js', {updates: {updates}});
The expected JSON format for the post data should resemble this:
$.post('/cart/update.js', {updates: {40076307207: 1}});
Your insights on resolving this issue would be greatly appreciated. Thank you!