i am trying to post data from my asp.net webform into database. i have this in my asp.net service (shoppingcart_service.asmx)
[WebMethod] //
public void RegisterSubscriber(string Email)
{
new OnlineShopTableAdapters.NewsletterSubscribersTableAdapter().Insert(Email, DateTime.Now);
//database code
}
this is my html
<input type="button" onclick="saveData()" id="btnSave" value="Subscribe" >
this is my ajax code, which i put in a file called apps.js and linked to my page
//updated ! function saveData() {
function saveData() {
var SubscriberEmail = $("#Email").val();
$.ajax({
type: "Post",
url: "shoppingcart_service.asmx/RegisterSubscriber",
data: '{"Email":"' + SubscriberEmail + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response.status + ' ' + response.statusText);
},
error: function (request, status, error) {
}
});
}
but the value doesn't get posted to my database consider the error i got in chrome's console, after clicking the subscribe button