本文介绍了使用ajax提交表单,但重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我想在表单上提交(a)执行某个php文件(url -a),我应该在html和jquery中使用什么? (b)重定向到另一个。(url -b)
What should I use in the html and in the jquery if I want upon form submit to (a) execute a certain php file (url-a); (b) redirect to another one.(url-b)
我目前实现了jquery表单插件。
I currently implemented the jquery form plugin.http://jquery.malsup.com/form/#getting-started
如下所示:
步骤a。包括jquery和表单插件脚本;
step a. included jquery and form plugin scripts;
步骤b。在html中,在表单元素中:
step b. in html, in the form element:
<form action="url-a.php">
<!--form code inserted here including input elements, etc and submit-->
</form>
步骤c。在js中,文档就绪
:
$('#form').ajaxForm(function() {
$.post("url-a.php", {a: a, b: b});
});
是否应更改其中一个网址链接?假设url-a是ajax应该处理的那个,我想重定向到url-b ..
Should one of these url links be changed? assume that url-a is the one the ajax should take care of, and I want to redirect to url-b..
谢谢!
推荐答案
$('#form').ajaxForm(function() {
$.post("url-a.php", {a: a, b: b});
window.location.href="/url-b.php";
});
这篇关于使用ajax提交表单,但重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!