When I send an integer to the backend , I receive it as a string , I can't figure out why ?
var formdata = new FormData();
for (var i = 0; i < scope.user.values.length; i++) {
formdata.append('values[]', scope.user.values[i]);
}
I receive values as string while they should be in integers
You actually cannot send integers
, everything will be in string format
and in key-value
pairs when you use formData
. Alternatively you can convert them to required datatype
in backend.
Know more about FormData here
All values sent by HTML to the server-side are received as strings. You have to convert that data into integers in the backside, which shouldn’t be too difficult. If you specify which language your server-side is using maybe we could let you know how to convert string into integers in it.=, or ever better, you can look it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With