AJAX PHP空白POST数据发送Godaddy



我似乎无法让这个简单的脚本在godaddy Web服务器上运行,但它在我的本地主机上运行良好。如有任何建议,我们将不胜感激!我几乎已经隔离了ajax没有将数据传递到另一个.php文件,我只是不知道为什么。我已经重写了很多次了。它在本地运行良好,只是在我的网络服务器上不正常。

pleaseworks.php

<?php
?>
<html>
<head>
<link rel="stylesheet" href="https://cdn.metroui.org.ua/v4.3.2/css/metro-all.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
</head>
<body>
<p id="test"> please work..</p>
<form>
<button type="button" onclick="clickit()">test it</button>
</form>
</body>
<script>
function clickit() {
$.ajax({
type: "POST",
url: "worked.php",
data: { workvariable: "I hope it worked" }
})
.done(function( response ) {
alert("Success.");
$("#test").html(response);
})
.fail(function()  {
alert("Sorry. Server unavailable. ");
}); 
}
</script>
</html>

worked.php

<?php
$workvariable = $_POST['workvariable'];
?>
<p id="pleasework">
<?php echo $workvariable; ?>
</p>

这与路径有关。WAMP的Localhost没有任何问题,但一旦在web服务器上,它就需要完整的路径。

谢谢大家!

最新更新