1
我在爲wordpress寫一個插件。該插件有一個包含按鈕和文本框的小部件。 該按鈕有onclick事件。 當發生此事件時,我需要將文本框數據發佈到php文件,使用ajax ajax代碼不會返回錯誤,但php不會獲取數據。wordpress插件中的ajax錯誤
這裏是我的JS文件
function F()
{
var x=document.getElementById('last').value;
jQuery.ajax({
type: "POST",
url: 'http://localhost/wordpress/wp-content/plugins/Hovo/Scripts/vote.php',
data: x,
success: function() {
alert('Sends successfully');
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
這裏是我的PHP文件
<?php
if(isset($_POST["anun"]))
{
echo $_POST['anun'];
}
else
{
echo "error";
}
?>
請幫忙解決這個問題
你確定本地主機?你在電腦上用於服務器端的東西?例如我usq麻,我的網站localhost:8888,或localhost:3000 – Legendary