M Fahad Farooqi
Please change the JS Code to
$("#submit-btn").on("click",function(e) {
$.ajax({
url: "https://ivr.callxl.com/callXLWeb/SendingEmail",
type: "POST",
contentType: "application/json; charset=utf-8",
data: { comment: $("#cmessage").val() },
dataType: "text",
success: function (data, textStatus, jqXHR) {
if (data.success) {
alert("successfully sent");
} else {
alert("not sent");
}
},
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText);
console.log("Something really bad happened " + textStatus);
$("#errorResponse").html(jqXHR.responseText);
}
});
e.preventDefault();
});
You can notice I moved the e.preventDefault(); statement from first line to end line of click event. Because e.preventDefault(); prevents the browser to execute the complete event.