I want to call the static method which is in server side by AJAX function which is in client side in asp.net. I have seen in debug mode also, but not getting in that method while there is no error also showing in windows console and for refer Google also the syntax also right. Then not getting me that why static method is not called by AJAX method.
Here is my code. This is client side code
<input type="submit" id="submit_mail" value="Send" />
<script>
$(function () {
$.ajax({
type: "POST",
url: "contact.aspx/SendMail",
data: JSON.stringify({ name: $('#txt_name').val(), email: $('#txt_emailID').val(), subject: $('#txt_subject').val(), message: $('#txt_content').val() }),
success: OnSuccess,
failure: function () {
alert("There is some problem in server to contact with us....Please contact with phone number...!!!");
}
});
});
function OnSuccess() {
$find("mpe").show();
return false;
}
</script>
This is the server side call
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static void SendMail(string name, string email, string subject, string message)
{
//here is the code
}
Now the issues is that only that after AJAX call this static method is not fired.