tom*_*mmi 3 html jquery dom jquery-mobile
在jQuery移动示例中.提交表单后显示的页面与表单POST-ing/GET-ing的位置相同.
将表单提交到URL并转移到DOM内的另一个页面是否可行?
您可以submit为表单的事件添加事件处理程序并手动提交表单,然后手动转换到您想要的任何页面.
$(function () {
$('#form_id').bind('submit', function (e) {
e.preventDefault();
$.post('path/to/file.php', $(this).serialize(), function (response) {
$.mobile.changePage('#page_to_goto', {transition: 'slide'});
});
});
});
Run Code Online (Sandbox Code Playgroud)
一些说明:
data-ajax="false"到表单标记来关闭表单的AJAX处理.e.preventDefault()阻止表单正常提交,return false;在事件处理程序结束时应该做同样的事情.$.post- http://api.jquery.com/jQuery.post/.serialize()- http://api.jquery.com/serialize/$.mobile.changePage()- http://jquerymobile.com/demos/1.0rc1/docs/api/methods.html| 归档时间: |
|
| 查看次数: |
4032 次 |
| 最近记录: |