I've been going around in circles trying to call a C# function with Ajax, and I'm think I'm making slow progress but I can't figure out why this webmethod is firing.
$.ajax({
type: "POST",
url: "/WriteToDatabase2.aspx/testMethod",
data: '{name: "' + inCompanyName + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
And my WriteToDatabase2.aspx.cs:
public partial class WriteToDatabase2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static void testMethod(string _name)
{ //string strPostVar = _name;
string strPos ...
Go to the complete details ...