日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ajax 参数大小限制,Ajax中的POST数据大小是否有限制?

發布時間:2025/3/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ajax 参数大小限制,Ajax中的POST数据大小是否有限制? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我正在嘗試使用jQuery Ajax將頁面中的數據數組發送到MVC Action。這是我的jQuery代碼:

$('#btnSave').click(

function () {

result = [];

$('#tblMatters tbody tr.mattersRow').each(function () {

if (!($(this).hasClass('warning'))) {

var item = {};

if ($(this).find('td.qbmatter > div.dropdown').length > 0) {

item.QBDescription = $(this).find('td.qbmatter > div.dropdown > a').text();

} else {

item.QBDescription = $(this).find('td.qbmatter').text();

}

var id = $(this).find("td:first > a").text();

item.Narrative = $("#collapse" + id).find("div.scrollCell").text();

item.WorkDate = $(this).find('td.workDate').text();

item.Hours = $(this).find('td.hours').text();

item.Person = $(this).find('td.person').text();

if ($(this).find('td.rate > div.dropdown').length > 0) {

item.Rate = $(this).find('td.rate > div.dropdown > a').text();

} else {

item.Rate = $(this).find('td.rate').text();

}

item.Amount = $(this).find('td.amount').text();

result.push(item);

}

});

var originalRecords = $("#tblSummary tr.summaryTotalRow td.summaryOriginalRecords").text();

var originalHours = $("#tblSummary tr.summaryTotalRow td.summaryOriginalHours").text();

var excludedHours = $("#tblSummary tr.summaryTotalRow td.summaryExcludedHours").text();

var totalHours = $("#tblSummary tr.summaryTotalRow td.summaryTotalHours").text();

$.ajax({

url: "/Home/SaveQBMatter",

type: "POST",

data: JSON.stringify({ 'Matters': result, 'originalRecords': originalRecords, 'originalHours': originalHours, 'excludedHours': excludedHours, 'totalHours': totalHours }),

dataType: "json",

traditional: true,

contentType: "application/json; charset=utf-8",

success: function (data) {

if (data.status == "Success") {

alert("Success!");

var url = '@Url.Action("Index", "Home")';

window.location.href = url;

} else {

alert("Error On the DB Level!");

}

},

error: function () {

alert("An error has occured!!!");

}

});

});

讓我解釋一下。我有一個動態生成的HTML表,我需要將此數據存儲到數據庫中。在jQuery中,我遍歷表有一個循環,我將result數組中每一行的數據存儲起來。然后,我使用Ajax將這些數據傳遞到MVC

Action中。

這是我的問題開始的地方…我已經意識到有時會按預期進行,但是有時我會從Ajax中收到錯誤消息。alert("An error has

occured!!!");現在我已經了解到,當result數組變大時會發生此錯誤。例如:如果包含100-150個項目>一切正常,但是當數量超過?150個時>錯誤。

Ajax中是否有任何POST限制?如何設置任何尺寸?我真的需要這個功能!請幫忙!

我的ActionResult代碼:

public ActionResult SaveQBMatter(QBMatter[] Matters, string originalRecords, string originalHours, string excludedHours, string totalHours) {

DBAccess dba = new DBAccess();

int QBMatterID = 0;

int exportedFileID = 0;

foreach (QBMatter qb in Matters) {

dba.InsertQBMatter(qb.QBDescription, qb.Narrative, qb.WorkDate, qb.Person, qb.Hours, qb.Rate, qb.Amount, ref QBMatterID);

}

ExcelTranslator translator = new ExcelTranslator();

translator.CreateExcelFile("", Matters, originalRecords, originalHours, excludedHours, totalHours);

return Json(new { status = "Success", message = "Passed" });

}

更新:找到了解決方案

JSON的最大長度!我需要增加這個值。在web.config中添加以下內容:

總結

以上是生活随笔為你收集整理的ajax 参数大小限制,Ajax中的POST数据大小是否有限制?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。