Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send integers in FormData

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

like image 479
user2099451 Avatar asked Nov 23 '15 12:11

user2099451


2 Answers

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

like image 141
Guruprasad J Rao Avatar answered Oct 21 '22 16:10

Guruprasad J Rao


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.

like image 38
Y2H Avatar answered Oct 21 '22 16:10

Y2H