Am having form inside the label type any message and click on "submit" it should call ajax and save in db
This is the Html code
<form role="form">
<label for="message">Message:</label>
<textarea class="form-control" id="cmessage"></textarea>
<button type="submit" id="msg-btn" class="btn btn-primary pull-right">Submit</button>
</form>
this is js code
$(document).ready(function() {
/* message */
What I have tried:
$(document).on("click","#msg-btn", function() {
$.ajax({
type: "POST",
url: "https://ivr.callxl.com/callXLWeb/SendingEmail",
data: "comment="+$("#cmessage").val(),
dataType: "text",
success: function(data, textStatus, jqXHR) {
if(data.success){
alert("success fully send");
}
else {
alert("Invalid Message");
}
},
// If there was no resonse from the server
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText);
console.log("Something really bad happened " + textStatus);
$("#errorResponse").html(jqXHR.responseText);
},
});
});