如何将变量从 js 文件传递到 php 文件。我想要变量从 checker.js 到 test.php
function SendData(id){
$.ajax({
type: "POST",
url: "test.php",
data: "id=" + id,
cashe: false,
success: function(response){
alert("Record successfully updated")
}
})
}
$(document).ready(function(){
SendData(10)
})
测试.php 文件
<?php
var_dump($_POST);
?>
索引.html
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="checker.js"></script>
</head>
<body>
</body>
</html>