post 大量的資料
發表於 : 週二 6月 05, 2012 3:04 pm
代碼: 選擇全部
$.ajax({
url: '<%=Url.Action("CustomerImport", "Api", new { area = "Mobile" })%>',
type: "POST",
data: '可裡面內容超出一定的大小',
contentType: "multipart/form-data",
enctype: "multipart/form-data",
encoding: "multipart/form-data",
dataType: "text",
success: function (data) {
// 略
},
error: function (xhr, ajaxOptions, thrownError) {
var errStr = xhr.status + ':' + xhr.responseText + thrownError;
}
});
server 怎麼接?
代碼: 選擇全部
[HttpPost]
public ActionResult CustomerImport()
{
string data = new StreamReader(Request.InputStream).ReadToEnd();
if (string.IsNullOrEmpty(data))
{
return new ObjectResult<Result[]>(new[] { new Result(2, "FAIL") });
}
//// LogManager.ApplicationLogger.Info("Content:" + data);
MobileContacts[] contacts = JSON.Helper.JsonToObject<MobileContacts>(data);
//// 略
}