我有一个通讯表单,我在我的网站上使用ajax与
jquery.我想向用户显示等待消息.
什么是最好的选择?
什么是最好的选择?
继承我到目前为止
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#submit').click(function(e) { $.ajax({ type: "POST",url: '/save.PHP',data: $('#form').serialize(),cache: false,success: function(result) { // my code when success } }); }); }); </script> <div id="newsletter"> <form id="form"> <label for="email">Your Email*:</label> <input name="email" value="" type="text" id="email" size="30" maxlength="255" /> <span id="submit">Submit</span> </form> </div>
谢谢
以下是您可以做的:
原文链接:https://www.f2er.com/php/139780.html创建一个div(消息对话框),并在用户按下提交时显示,并在ajax完成后将其隐藏.
我也建议使用jQuery验证插件验证电子邮件.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#submit').click(function(e) { // validation $.ajax({ type: "POST",url: '/file.PHP',success: function(result) { // do what ever you need },error: function (response,desc,exception) { // alert some message },beforeSend: function() { $('#loader').fadeIn(1000); },complete: function() { $('#loader').fadeOut(1000); },}); }); }); </script> <style type="text/css"> #loader { display: none; /* and other css youy need like border,position,etc... */ } </style> <div id="loader">loading ...</div> <div id="newsletter"> <form id="form"> <label for="email">Your Email*:</label> <input name="email" value="" type="text" id="email" size="30" maxlength="255" /> <span id="submit">Submit</span> </form> </div>