Javascript Ajax Post脚本在js表单中不起作用
我在Pretto中创建了一个表单作为内联内容。表单弹出很好用。 在提交表单时,我有一个Ajax post脚本,它调用php脚本来发送电子邮件。但是这个Ajax post调用不起作用。试图找出如何在表单提交中添加ajax脚本 Ajax脚本Javascript Ajax Post脚本在js表单中不起作用,javascript,jquery,ajax,forms,prettyphoto,Javascript,Jquery,Ajax,Forms,Prettyphoto,我在Pretto中创建了一个表单作为内联内容。表单弹出很好用。 在提交表单时,我有一个Ajax post脚本,它调用php脚本来发送电子邮件。但是这个Ajax post调用不起作用。试图找出如何在表单提交中添加ajax脚本 Ajax脚本 $("#getStartedForm").submit(function() { alert("form works!"); $.ajax({ type : "POST", url : "send_mail11.p
$("#getStartedForm").submit(function() {
alert("form works!");
$.ajax({
type : "POST",
url : "send_mail11.php",
dataType : "html",
data : $(this).serialize(),
beforeSend : function() {
$("#loadingNews").show();
},
success : function(response) {
$("#responseNews").html(response);
$("#loadingNews").hide();
$('#responseNews').delay(5000).fadeOut();
$('#subscribeInput').val("");
}
})
return false;
});
HTML:
<a href="demoform" rel="prettyPhoto">Start</a>
<div id="demoform">
<form id="getStartedForm" action="#" method="post">
<div id="responsenews"></div>
<input type="text" id="firstName"/>
<input type="text" id="eMail"/>
<textarea id="commmentBox"></textarea>
<input type="submit" id="submitBtn" value="send mail"/>
</form>
</div>
Pretty Photo正在其容器中克隆内联元素,因此绑定到实际内联元素的DOM的事件将无法工作
您可以尝试使用ajax解决方案,或者通过挂接到Pretty Photo的事件来进行一些自定义编码,以初始化提交事件绑定到克隆元素。您可以为相同的元素创建小提琴吗。您可以尝试使用changepicturecallback:function(){},/*在每次显示/更改项目时调用它吗*/