Angularjs $http not working if data too long

Viewed 42

I am try to use $http to submit the form to backend and it is working fine at the beginning.

$http({
    method : "POST",
    url    : "handleformurl",
    params : [{user:"Peter",age:"25",gender:"m"},{user:"Chris",age:"23",gender:"m"}]
})

Server side can receive all the data without any problem. However, error occurred when I try yo submit the huge form with the same format

$http({
    method : "POST",
    url    : "handleformurl",
    params : [{user:"Peter",age:"25",gender:"m"}, + over 2000 user info in the list]
})

The total length of params is over 200000 characters and I found that server side can't receive anything. Then I try to check the response of $http but only limited information is provided

"data":null,"status":-1,"statusText":"","xhrStatus":"error"

I can't locate the root cause now but it seems there is a limitation for the length. Is that any configuration or setting that can fix this issue?

1 Answers

You could create an object to pass, for example:

var userInfo = { 
  user: "Peter", 
  age:"25",
  gender:"m"
  ...
}

Then, you can pass this object in the Post:

$http({ method: "POST", url: handleformurl, data: userInfo });
Related