以下HTML页面应该传递请求参数并使用post params调用,但它似乎不起作用。
<html>
<head>
<meta charset="ISO-8859-1">
<title>Processing</title>
<script type="text/javascript">
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
return vars;
}
function post() {
var form = document.createElement("form");
form.setAttribute("method", "post");;
form.setAttribute("action", "https://demo.bank.com/B001/path");
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
</script>
</head>
<body onload="post();">
</body>
</html>
我做错了什么或者还有其他方法可以做我想做的事吗?