Click here to Skip to main content
16,019,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
if i enter a text in the textarea of the html tag it is not assigned to the variable in the ajax 'comment'
can anyone help me.thankyou.
Posted
Updated 13-Jul-16 2:22am
v2
Comments
Richard Deeming 13-Jul-16 8:26am    
Removing the content of your questions after they have been answered is extremely rude.

1 solution

JavaScript
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. 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900