[英]AJAX Internal 500 Error in Wordpress Children-Theme
我在Js / Jq塊(/buscador/menuLateral/menu-libros.php)上獲得了這個Ajax代碼:
$.ajax({
url: '<?= get_stylesheet_directory_uri(); ?>' +
'/buscador/buscador-functions.php',
type: 'POST',
data: {
sendCheckedVal: 'yes',
tipo: 'editorial',
valor: valor_recogido,
archivo: this_file_id.toString()
},
success: function(data) {
alert('Checked value !');
}
});
該文件上的值存在並且具有一定的價值,我嘗試在Stringify上使用GET對其進行查看。
而且,必須將其放入這樣的文件中( /buscador/buscador-functions.php) :
<?php
if (ISSET($_POST['sendCheckedVal'])){
echo 'hi, u reached here' ;
}
?>
值不會從js代碼文件傳遞到next。
我在控制台上收到此錯誤:
開機自檢[WP-URL-隱藏時目的] /themes/ChildrenNewspaper/buscador/buscador-functions.php 500(內部服務器錯誤)
在行錯誤的右側:
jquery.min.js:2
有人知道如何在使用wordpress主題的ajax上修復此問題。
問題在這里: alert('hi, u reached here');
。 alert()
不是PHP
函數,而是javascript
函數。 因此,您可以使用echo
或return
代替它
<?php
if (isset($_POST['sendCheckedVal'])){
echo 'hi, u reached here';
}
?>
首先, alert
是一個javascript函數。 在php中,您需要向頁面echo
值;
如果要使用JS進行打印,則需要打印出js。
echo "<script type='text/javascript'>alert('hi, u reached here');</script>";
或者你可以echo
出瓦爾頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.