[英]Page refresh with post request
In our application, we need to refresh the page. 在我们的应用程序中,我们需要刷新页面。 Now I am using the onclick()
event to call the below javascript method. 现在我使用onclick()
事件来调用下面的javascript方法。
function refresh() {
document.getElementById('Question-Preview-ComboBox').style.display='none';
document.getElementById('Question-Preview-RelatedSRTicketDetails').style.display='none';
document.getElementById('Question-Preview-SignoffdetailControl').style.display='none';
document.getElementById('Question-Preview-RelatedTicketDetails').style.display='none';
document.getElementById('Question-Preview-PerformedBy').style.display='none';
document.getElementById('Question-Preview-TextBox').style.display='none';
document.getElementById('Question-Preview-CheckBoxMatrix').style.display='none';
document.getElementById('Question-Preview-Radio').style.display='none';
document.getElementById('Question-Preview-CheckBoxMatrixWOT').style.display='none';
document.getElementById('Question-Preview-MultiLineText').style.display='none';
if (windowDirty == true) {
showModal('doyouwanttosave');
}
else {
self.location = 'CreateQuestionnaireForm.html';
}
}
The above script will ask users before they refresh the page "Do you want to save" and will make a GET request to call the controller method to reload the page. 上面的脚本会在用户刷新页面“你想要保存”之前询问用户,并且会发出GET请求来调用控制器方法来重新加载页面。 But our requirement is to change the GET request to POST for the above same functionality. 但我们的要求是将GET请求更改为POST以获得上述相同的功能。 Please suggest how can I change a GET request to POST? 请建议如何将GET请求更改为POST?
您需要创建一个隐藏的表单,将其添加到文档中,然后通过调用表单的DOM对象上的.submit()
来提交它。
Include the form tag and specify the action method as post 包括表单标记并将操作方法指定为post
<form action="destination_url" METHOD=Post>
....
<input type=submit value="Submit" />
</form>
你需要创建一个表单并提交它 - 而不是你有邮寄请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.