大佬教程收集整理的这篇文章主要介绍了jquery-mobile – jQuery Mobile中的AJAX表单提交,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
看来,当我提交表单(通过POST)时,表单参数会被添加到url中.不仅如此,他们还删除了表单提交前我所处的锚定页面.
例如,我在localhost:8080 / myapp /#sign_up页面上
然后我提交表单,使url成为:localhost:8080 / myapp /?email=a@a.com\u0026amp; pass = pass
因此,如果我点击验证错误并单击“后退”按钮,我就不会返回到#sign_up页面.
有任何想法吗?
//bind an event handler to the submit event for your login form $(document).on('submit','#form_id',function (E) { //cache the form element for use in this function var $this = $(this); //prevent the default submission of the form e.preventDefault(); //run an AJAX post request to your server-side script,$this.serialize() is the data from your form being added to the request $.post($this.attr('action'),$this.serialize(),function (responseData) { //in here you can analyze the output from your server-side script (responseData) and validate the user's login without leaving the page }); });
要阻止jQuery Mobile运行自己的表单的AJAX sumbission,请将其放在表单标记上:
<form data-ajax="false" action="...">
以上是大佬教程为你收集整理的jquery-mobile – jQuery Mobile中的AJAX表单提交全部内容,希望文章能够帮你解决jquery-mobile – jQuery Mobile中的AJAX表单提交所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。