如何将GET请求转换为POST [英] How to convert a GET request to POST
本文介绍了如何将GET请求转换为POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道是否可能.我推荐了一些网站,但没有得到确切答案.
I don't know if it is possible or not. I referred some site, but I didn't get exact answer.
I am using
<a href="xyz?id=4"> click </a>
当我在响应页面中轻松地将此请求发送到服务器时,我可以在地址栏中看到"id = 4" ,这显然是不安全的,但是在发布请求中我们看不到这一点.
When I send this request to server in the response page easily I can see "id=4" in address bar, obviously which is not secure, But in post request we cant see this.
所以我们可以将get请求转换为post或ant吗?可以通过其他方式将其隐藏在地址栏中.
So can we convert a get request to post or ant other way is there to hide this from address bar.
谢谢.
推荐答案
<a href="#" onclick="postForm()"> click </a>
动态创建一个发件人并将其发布.
Dynamically create a from and post it.
function postForm() {
var form = $('<form method="POST" action="xyz"></form>');
$(document.body).append(form);
form.append('<input type="hidden" name="id" value="4"/>');
form.submit();
}
正如Racil在评论中建议的那样,您还可以执行以下操作
As Racil suggested in comments, you can also do the following
<a href="#" id="postLink"> click </a>
然后
$('#postLink').click(function(e){
e.preventDefault();
//create form and post
});
这篇关于如何将GET请求转换为POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文