使用jQuery传递POST数据时打开URL [英] Open URL while passing POST data with jQuery
本文介绍了使用jQuery传递POST数据时打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在将帖子数据传递到新页面时,是否可以使用jQuery更改页面URL?
Is it possible using jQuery to change the page URL while passing post data to the new page?
推荐答案
如果您要更改当前页面的网址,那么可以在当前页面中添加一个新的<form>
页面,向其中添加隐藏的输入元素,然后提交.
If you mean that you want to change the current page URL, well then you can add a new <form>
to the current page, add hidden input elements to it, and then submit it.
$('body').append($('<form/>')
.attr({'action': yourNewURL, 'method': 'post', 'id': 'replacer'})
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'param1', 'value': "hello"})
)
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'param2', 'value': "world"})
)
).find('#replacer').submit();
或类似的东西
这篇关于使用jQuery传递POST数据时打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文