[英]Redirect from Javascript to Php without form submission
I need to redirect to a php page with informations by POST when a user click on an image. 当用户单击图像时,我需要通过POST重定向到包含信息的php页面。
Here's the way I do it for now : 这是我现在做的方法:
function redirect(id) {
var url = 'newPage.php';
var form = $('<form action="' + url + '" method="post">' +
'<input type="text" name="prankId" value="' + id + '"/>' +
'</form>');
$('body').append(form);
form.submit();
}
With Javascript, I create a form with my input and I submit it. 使用Javascript,我用输入创建一个表单,然后提交。 But when i reload the page (that I redirected to), it ask me to resubmit my form.
但是,当我重新加载页面(重定向到该页面)时,它要求我重新提交表单。 Is there a way to do it where I wouldn't have to resubmit it?
有什么方法可以不必重新提交吗?
您可以使用GET而不是POST请求,也可以使用POST / REDIRECT / GET模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.