0
我正在使用Magnific Popup。在彈出窗口中我有一個表單。在表單提交中,我想顯示來自php表單處理文件的文本。現在頁面只是刷新,並不確定它掛着什麼。使用magnifica-popup提交表單並顯示錶單結果
<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>