我使用http://okonet.ru/projects/modalbox/index.html的項目'ModalBox'來生成我的模態。通過模態框提交表單而不離開頁面/模式
我也在使用這個總體腳本,它將通過表單提交的電子郵件持久化爲一個簡單/快速的解決方案,將其作爲基本文本文件提交。 http://www.knowledgesutra.com/forums/topic/25586-php-simple-newsletter-script/
雖然我有兩難困境。 爲了保持模式並顯示我的'mailing_thankyou.php'我的表單必須有'onsubmit =「return false」'但爲了讓我的PHP腳本能夠正常工作,我必須刪除那個返回false,但是它會改變到一個新的頁面,以堅持這一信息。
有沒有人有任何想法?
這是問題的主要部分:
myModal.html
<div id="signUp">
<form action="mailer/mailing.php" id="myForm" method="post" class="style16">
<input type="text" name="email" size="30" value="your email here!">
<input type="submit" value="Send link" name="submit" onclick="Modalbox.show('mailer/mailing_thankyou.php', {title: 'Form sending status', width: 500, params:Form.serialize('myForm') }); return false;">
or <a href="#" title="Cancel & close dialog" onclick="Modalbox.hide(); return false;">Cancel & close</a>
<!-- ><input type="submit" value="GO!" name="submit"> -->
</form>
</div>
你可以從我的git倉庫拉我的文件: https://github.com/jwmann/Modal-Sign-up
嘗試ajax後onsubmit到您的mailing.php文件,然後成功,你可以調用Modalbox.show。你可以使用jQuery嗎?它非常簡單,例如: $ .post('mailer/mailing.php',function(data){ Modalbox.show(...); }); – squidbe 2011-06-01 07:20:57