繁体   English   中英

Wordpress儿童主题中的AJAX内部500错误

[英]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函数。 因此,您可以使用echoreturn代替它

<?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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM