我有以下jQuery
$("button#submit").click(function(){
$.ajax({
type: "POST",
url: "process.php",
data: $('form.contact').serialize(),
success: function(msg){
$("#form-content").modal('hide');
$("#thanks").html(msg);
$("#thanks").delay(2000).fadeOut("slow");
},
error: function(){
alert("failure");
}
});
});
和PHP
<?php
if (isset($_POST['name'])) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['Email']);
$sug = strip_tags($_POST['sug']);
echo "<span class='label label-info'>Your Website has been submitted .. Thank you</span>";
}?>
这是第一次工作,并在我的页面上显示php echo。但是,当我再次提交表单时,它不会显示。
参考方案
您的$("#thanks")
dom隐藏。
$("button#submit").click(function(){
$.ajax({
type: "POST",
url: "process.php",
data: $('form.contact').serialize(),
success: function(msg){
$("#form-content").modal('hide');
$("#thanks").html(msg);
$("#thanks").show(); <----------------ADD THIS
$("#thanks").delay(2000).fadeOut("slow");
},
error: function(){
alert("failure");
}
});
});
jQuery ajax()返回json对象,但未正确警告 - php为什么无法使用data [0] .id返回ID? $(document).ready(function(){ $.ajax({ type: 'POST', dataType: "json", url: '<?php echo matry::base_to('tests/map_it'…
jQuery-找不到Ajax网址 - php好的,我敢肯定这确实很容易,而且我很愚蠢,但是似乎并不能深入了解它。我试图从我的js文件“ custom.js”中对“ helpers.php”中的某些代码进行简单的AJAX调用。但是,我仍然收到404错误,因为我似乎并没有正确遍历文件夹,尽管我确信我正在...我的文件夹结构如下:html index.php js/ custom.js includes h…
jQuery Ajax和php类 - php我正在尝试学习如何在php中使用oop。我对jQuery也很陌生。是否可以向php类方法发出Ajax请求?我只将Ajax请求发送到专门用于此目的的文件,并且返回我需要的数据。 参考方案 简短答案:不可以。长答案:Ajax只是一个使用JavaScript从浏览器发出HTTP请求而无需离开页面的术语。您唯一可以“呼叫”的是URL。您可以编写PHP以根据URL来执…
AJAX实时电子邮件验证(PHP) - php当用户在我的网站上创建帐户时,我希望对照我的数据库(MySQL)中的所有当前用户名检查输入的用户名,并确认是否可用。有谁知道我可以使用的任何好的库,或者是jQuery的插件? 参考方案 所需的确切信息以示例形式here给出。它使用jQuery作为JavaScript库
jQuery Ajax:使用单个请求将响应分配给两个变量 - php我正在使用JQuery Ajax从MySQL数据库收集数据。我的PHP脚本如下所示:$categorias= array_map(function($a) { return ($a["categorias"]); }, $rows); $real = array_map(function($a) { return floatval($a[…