jquery表单成功显示从服务器生成的消息
我有jquery表单成功显示从服务器生成的消息,jquery,Jquery,我有 在这里,您可以使用任何变量来存储AJAX响应,而不是使用函数(数据)尝试使用以下代码,而不是您现有的代码 $.ajax({ type: "POST", url: "the/form", data: $(\'.target\').serialize(), success: function(data) { // data is a callback variable which stores info echoed in PHP file during transf
在这里,您可以使用任何变量来存储AJAX响应,而不是使用函数(数据)尝试使用以下代码,而不是您现有的代码
$.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function(data) { // data is a callback variable which stores info echoed in PHP file during transfer, so you have to $message there to get it here
alert(data); // this will alert it
}
});
您必须在ajax文件(the/form)中回显消息不确定为什么,但当回显“data”不返回任何内容时,我仍然接受这个答案。
$.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function() {
alert("done");
// how to show the infoMessage ?
}
});
$.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function(data) { // data is a callback variable which stores info echoed in PHP file during transfer, so you have to $message there to get it here
alert(data); // this will alert it
}
});
$.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function(data) {
alert(data); //data contains the ajax response
$("#infoMessage").html(data); //you set here where to ajax response will be displayed
}
});
$.ajax({
type: "POST",
url: "the/form",
data: $(\'.target\').serialize(),
success: function(data) {
//alert("done");
$('#infoMessage').html(data);
}
});