我有一个表单,我使用ajax调用asmx Web服务提交。但是,数据成功插入到数据库中;既没有触发成功或错误功能。第一个警报有效。有什么想法吗?
我的jQuery:
$("#AddSupplierBtn").click(function()
{
alert("This is the first alert");
if ($("#AddSupplier").valid())
{
$.ajax({
type: "POST",
url: "/StockPileDelivery.asmx/TestMethod",
data: JSON.stringify({
SupplierName: $('#SupplierName').val(),
SupplierType: $('#SupplierType').val(),
SupplierPremium: $('#SupplierPremium').val(),
SupplierLocation: $('#SupplierLocation').val()
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("Working - " + msg.d);
},
error: function (xhr,status,error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
},
});
}
});
答案 0 :(得分:0)
我将以下按钮类型从提交更改为按钮,然后就可以了:
<button type="button" class="btn btn-primary" id="AddSupplierBtn" name="AddSupplierBtn">Submit</button>