[英]How to post data (form) without page refresh PHP, jQuery, Ajax
[英]jQuery post without a form but with page refresh
是否可以仅使用jQuery将POST数据提交到PHP脚本,页面上没有表单并且页面刷新?
重定向
$(document).ready(function(){
$('.button').click(function(){
window.location.replace('index.php?some_value=1');
});
});
在此示例中,将发送GET数据,但如何使用此重定向发送POST数据?
POST
$(document).ready(function(){
$('.button').click(function(){
$.post(
'index.php',
{
some_value: '1'
}, function(result) {
alert(result);
}
);
});
});
此示例不会刷新页面。
您可以隐藏表单,以便在表单中包含数据,然后自己“提交”。
如果你包括
style="display:none"
在你的形式这样
<form style="display:none" action="POST">
<input field your input field>
<input maybe another input field>
</form>
然后你仍然可以通过邮寄提交但没有显示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.