例如: jQuery的:
var sendTemp=[];
var t={
string:'this is test string1',
time: '2017-03-20T04:25:06.584Z',
type:'file',
location:'usa',
broken:false,
}
我测试var max
值数组以发送服务器,
当max
> 500~600服务器返回错误消息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){
}
});
我在app.js
中找到了解决方案,但没有成功的node.js:
设置限制:
var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
设置端口:
app.post('/send',function(req, res, next){
console.log(req.body);
res.end();
});