您可以通过 HTML5 FormData 将数据异步发送到其他页面来执行相同操作。这是代码:
<form action="1.php" onsubmit="sendData()" id="myForm">
<input type="text" name="value1">
<input type="text" name="value2">
</form>
<script>
function sendData()
{
var formData = new FormData(document.getElementById('myForm'));
$.ajax({
url: '2.php', //Server script to process data
type: 'POST', //POST or GET
xhr: function()
{ // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
return myXhr;
},
data: formData, //form data
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}