将大数据发送到服务器
是否可以将$.ajax
大量数据(例如网格内容)发送到控制器? 是否存在“URI太长”的变通方法? 我知道这可能不是最好的做法,相反我应该逐个发送每一行,但仍然可能吗?
是否存在“URI太长”的变通方法?
使用POST HTTP谓词而不是GET:
$.ajax({ url: '/foo', type: 'POST', data: { value: someVariableThatCouldBeHuge }, success: function(result) { // TODO: process the results } });
或等效的:
$.post('/foo', { value: someVariableThatCouldBeHuge }, function(result) { // TODO: process the results });