Ajax调用不起作用这个代码中还有其他东西。请帮忙 [英] Ajax call is not working is there any thing else in this code.please help
问题描述
我在标签内部有任何形式的消息并点击提交它应该调用ajax并保存在db
这是Html代码
< form role =form>
< ; label for =message>消息:< / label>
< textarea class =form-controlid =cmessage>< / textarea>
< button type =submitid =msg-btnclass =btn btn-primary pull-right >提交< / button>
< / form>
这是js代码
$(文件).ready(function(){
/ * message * /
我尝试过:
$(文件).on(点击 ,#msg-btn,函数(){
$ .ajax({
类型:POST,>
url:https://ivr.callxl.com/callXLWeb/SendingEmail,
数据:comment =+ $(#cmessage)。va l(),
dataType:text,
成功:函数(data,textStatus,jqXHR){
if(data.success){
alert(成功完全发送);
}
else {
alert(无效消息);
}
},
//如果没有来自服务器的共鸣
错误:函数(jqXHR,textStatus,errorThrown){
alert(jqXHR.responseText);
console .log(发生了非常糟糕的事情+ textStatus);
$(#errorResponse)。html(jqXHR.responseText);
},
});
});
(文件).ready(功能()
/ * message * /
我尝试过:
(document).on(click,#msg-btn, function(){
Am having form inside the label type any message and click on "submit" it should call ajax and save in db 这篇关于Ajax调用不起作用这个代码中还有其他东西。请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
类型:POST,
url:https://ivr.callxl.com/callXLWeb/SendingEmail,
数据:comment =+
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);
},
});
});(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="+