首页 > 解决方案 > 当 jquery ajax 调用的 aspx web 方法具有超过 8 个参数时无法访问

问题描述

我的 aspx web 方法有 10 个参数。当 jquery ajax 调用的 aspx web 方法具有超过 8 个参数时,我无法访问。8个参数方法可以无错误地访问。唯一的问题是调用这 10 个参数的方法时。我收到 500 个内部错误。

我的阿贾克斯电话:

var updatedata = '{slNo: "' + GsSlNo + '", oldCategoryName: "' + GsItemCategory + '", newCategoryName:"' + $('#ddlCategoryName').val() + '", itemName: "' +
                   $('#txtItemName').val() + '", modelNo: "' + $('#txtModelNo').val() + '", stockQty: "' + $('#txtStockQty').val() + '", description: "' +
                   $('#txtDescription').val() + '", imageString: "' + imgData + '", fileName: "' + sFileName + ', oldImagePath:"' + GsItemImagePath + '"}';

            $.ajax({
                type: "POST",
                url: "sitesettings.aspx/UpdateItemMaster",
                data: updatedata,
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",

我的 aspx 网络方法

[System.Web.Services.WebMethod]
    public static long UpdateItemMaster(string slNo, string oldCategoryName, string newCategoryName, string itemName, string modelNo, string stockQty, string description, 
                                        string imageString, string fileName, string oldImagePath)

标签: asp.netwebmethodsjquery-ajaxq

解决方案


像这样改变数组。

var params = new Object();
params.slNo = GsSlNo;
params.oldCategoryName = GsItemCategory;
.
.
.
params.stockQty= $('#txtStockQty').val();

 $.ajax({
                type: "POST",
                url: "sitesettings.aspx/UpdateItemMaster",
                data: data:JSON.stringify(params),
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",

推荐阅读