我正在使用 Magnific Popup。在弹出窗口中,我有一个表格。在表单提交时,我想显示 php 表单处理文件中的文本。现在页面刚刚刷新,不确定它挂在什么上面。
<form name="subscribe" id="subscribe" class="subscribe" action="">
<p><input name="subscribe" type="checkbox" value="yes">text here</p>
<input name="submit" type="submit" value="Submit">
</form>
<?php
echo "thanks";
?>
<script type="text/javascript">
(function($) {
// open the popup
$(window).load(function () {
$.magnificPopup.open({
items: {
src: '#my-popup',
type: 'inline'
},
//add options here,
closeOnBgClick: false,
closeOnContentClick:false
}, 0);
});
// close the window no thanks button
$('#button').click(function() {
$.magnificPopup.close();
});
// submit form and show results text
$('#submit').click(function() {
$.ajax({
type: "POST",
url: test.php,
data: $("#idForm").serialize(),
success: function(data)
{
alert('ok');
alert(data); // show response from the php script.
}
});
});
})(jQuery);
</script>