I am trying to call a C # method from a java script, I am new to web development, and after a bit of searching based on using jquery to do the same, the way I am trying to call a method:
$.ajax({
type: "POST",
url: "Default.aspx/IncrementJ",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert("success!")
}
});
here IncrementJ is my function name, defined in C #, which I want to call. Here is the definition:
[WebMethod]
public static void IncrementJ()
{
try
{
j++;
}
catch (Exception ex)
{
throw ex;
}
}
when I run my program, the web console gives an error message "cannot find incrementJ resource", tell me where I am mistaken,
Thank.
source
share