使用window.location.href传递post数据 [英] pass post data with window.location.href

查看:928
本文介绍了使用window.location.href传递post数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用window.location.href时,我想将POST数据传递给我正在打开的新页面。可以使用JavaScript和jQuery吗?

When using window.location.href, I'd like to pass POST data to the new page I'm opening. is this possible using JavaScript and jQuery?

推荐答案

使用 window.location.href 无法发送POST请求。

Using window.location.href it's not possible to send a POST request.

您需要做的是设置表单包含数据字段的标记,将表单的 action 属性设置为URL,将方法属性设置为POST,然后在表单标记上调用 submit 方法。

What you have to do is to set up a form tag with data fields in it, set the action attribute of the form to the URL and the method attribute to POST, then call the submit method on the form tag.

这篇关于使用window.location.href传递post数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆