for example: jQuery:
var sendTemp=[];
var t={
string:'this is test string1',
time: '2017-03-20T04:25:06.584Z',
type:'file',
location:'usa',
broken:false,
}
I test the var max value array to send server,
when max > 500~600 server return error message payload too large problem.
var max=600;
for(var i=0;i<max;i++){
sendTemp.push(t);
}
$.ajax({
async:false,
url:"/send",
type:"POST",
data:{
sendTemp:JSON.stringify(sendTemp),
},
success:function(data){
},
error:function(jqXHR, textStatus, errorThrown){
}
});
I found a solution but did not work,in app.js
node.js:
set limit:
var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
set port:
app.post('/send',function(req, res, next){
console.log(req.body);
res.end();
});
I faced same issue. I did ajax post and got 413 payload too large error. By checking net and documentation I solved this problem by setting limit directly to body-parser.
app.use(bodyParser({limit: '50mb'}));
I hope this will be useful.
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