问题
Here is my Jquery ajax method:
$(document).ready(function () {
$("input[id$='btnBulten']").click(function () {
//alert("dd");
$.ajax({
type: "POST",
url: "http://URL/Controls/EBulten.ascx/EBultenSend",
contentType: "application/json; charset=utf-8",
data: "{nameSurname:" + $("input['id$='$txtNameSurname']").val() + " }",
dataType: "json",
success: function (msg) {
alert("Mesajınız başarıyla iletildi");
}
});
});
});
and in codebehind code:
[WebMethod()]
public static void EBultenSend(string nameSurname, string email, string IP, string position, string firmName)
{
int bultenId = EBulten.InsertEbulten(nameSurname, email, IP, position, firmName);
}
InsertEBulten calling SP to save data to DB. All parameters comes from TextBoxes. I am not able to save data to database.How can I fix this? Normally, without WebMethod, if I use this method on client click, it inserts data to DB.
来源:https://stackoverflow.com/questions/16083123/save-data-to-db-using-jquery-ajax-on-button-click