這裏是我的Ajax功能:阿賈克斯不能調用Web窗體在asp.net的WebMethod和C#
function createSalesInvoice() {
var SalesInvoice = {};
SalesInvoice.PaidAmount = $("#textbox1").val();
SalesInvoice.RemainingAmount = $("#textbox2").val();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/AjaxRequestToServer.aspx/createSalesInvoice", //URI
data: '{SalesInvoice: ' + JSON.stringify(SalesInvoice) + '}',
dataType: "json",
success: function (data) {
bootbox.alert("Item Added Successfully", function (e) { });
GetSalesInvoiceItemsList();
$("#hdfFlag").val("false");
},
error: function (xhr) {
}
});
}
我不敢說我的[webmethod]
。文本框中的所有值都返回正確。我想在表格中插入這些值。
[WebMethod]
public static int createSalesInvoice(SalesInvoiceEntity SalesInvoice)
{
int i = SalesInvoiceManager1.createSalesInvoice(SalesInvoice);
return i;
}
您在createSalesInvoice()中添加了[WebMethod]屬性了嗎? –
@HamedJavaheri yes .. plz查看編輯問題我的webmethod –
你檢查了你的數據屬性是否正確? – Komal