使用POST数据打开Window.open()并使用PHP获取数据 [英] Open Window.open() With POST Data and get data with PHP

查看:261
本文介绍了使用POST数据打开Window.open()并使用PHP获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有用户名和密码的表格.当我单击提交"按钮时,用户名和密码将传递到另一页并打开新窗口.

I have form with username and password. when i click on submit buttom then username and password will pass to another page and open new window.

我知道我将像GET请求一样传递此数据

i know that i will pass this data by GET request like

window.open('url.php?unm=username&pass=password','_blank');

但就我而言,我不想在url中显示数据.我想使用POST方法在url.php页面中获取数据.

but in my case i don't want to display data in url. I want to use POST Method To get data in url.php page.

那么如何做到这一点.请帮助..谢谢您提前

So How to do this. Please Help.. Thanks For Advance

以下我使用的代码:

$.post("url.php?unm=username&pass=password",function(data){
    $("#form").hide();
});

推荐答案

您需要处理表单提交,然后打开新窗口

You need to do with form submit and then open new window

<form id="Form" method="post" action="url.php" target="TheWindow">
<input type="hidden" name="unm" value="" />
<input type="hidden" name="pass" value="" />
</form>
<script>
function Post(name,password) {
  var f = document.getElementById('Form');
  f.unm.value = name;
  f.pass.value = password;
  window.open('', 'TheWindow');
  f.submit();
} 
Post("username","password");
</script>

这篇关于使用POST数据打开Window.open()并使用PHP获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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