Php jqueryajax失败

Php jqueryajax失败,php,jquery,ajax,Php,Jquery,Ajax,我正在尝试向PHP页面发送ID以更新数据库。第一次使用AJAX 我总是出错。PHP文件位于同一目录中 function approve(id) { $.smallBox({ title : "Are you sure you would like to approve this indicator?", content : "<p class='text-align-right'><a href='javascr

我正在尝试向PHP页面发送ID以更新数据库。第一次使用AJAX

我总是出错。PHP文件位于同一目录中

function approve(id) {

        $.smallBox({
            title : "Are you sure you would like to approve this indicator?",
            content : "<p class='text-align-right'><a href='javascript:approve_indicator(" + id + ");' class='btn btn-primary btn-sm'>Yes</a> <a href='javascript:void(0);' class='btn btn-danger btn-sm'>No</a></p>",
            color : "#296191",
            //timeout: 8000,
            icon : "fa fa-bell swing animated"
        });


}

function approve_indicator(id){
        $.ajax({
              url: '/approve_indicator.php',
              type: 'post',
              data: 'id='+id,
              success: function() 
              {
                  alert('success, server says '+output);

                  location.reload();

              }, error: function()
              {
                  alert('something went wrong, rating failed');
              }
        });

}

PHP代码包含
preapre
而不是
prepare
。这可能会给你带来不想要的结果。此外,使用Firebug等web工具可以查看AJAX响应。如果显示PHP错误,响应将告诉您PHP代码的错误。

“错误”。什么错误?approve_indicator(id)功能的错误消息:警报(“出现了问题,评级失败”);这应该告诉您使用正确的错误处理程序,而不是那些通用的错误处理程序。jQuery为
error
提供了3个有用的参数。。。我不熟悉AJAX,也不熟悉Jquery。如果这三行是
approve\u indicator.php
中唯一的一行,那么除非
$update\u indicator->execute(数组(1,$id))回应了一些东西,
$。ajax
成功的条件永远不会发生。您是否研究过使用web开发人员工具来查看实际响应是什么?我将尝试。。。就像检查元素一样?如何检查响应?在Firebug中,您可以在控制台选项卡下找到它,如:。每个工具的确切位置可能不同,我知道了。起初,这是一个内部服务器错误,因为我忘记在另一个PHP文件中包含connect文件。然后脚本中有一个未定义的变量。
$id = $_POST['id'];
$update_indicator = $con->preapre("UPDATE indicators SET approved = ? WHERE indicator_id = ?");
$update_indicator->execute(array(1,$id));