Ajax POST 500内部错误

时间:2016-09-13 13:48:12

标签: php jquery ajax

我的ajax调用有问题。它给了我下面显示的错误。我在这里和谷歌一起寻找问题,但我找不到解决方案。所以,我希望有人可以犯下我所犯的错误。

console.log表明变量工作正常。所以我知道100%的错误是在ajax调用中。

jquery-2.1.1.min.js:4 POST http://localhost:8888 500 (Internal Server Error)
send 
@ jquery-2.1.1.min.js:4
ajax @ jquery-2.1.1.min.js:4
(anonymous function) @ script.js:61
if (isConfirm) {
                    var aanhef = $('select[name="aanhef"]').val();
                    var username = $('input[name="username"]').val();
                    var achternaam = $('input[name="achternaam"]').val();
                    var adres = $('input[name="adres"]').val();
                    var plaats = $('input[name="plaats"]').val();
                    var postcode = $('input[name="postcode"]').val();
                    var email = $('input[name="email"]').val();
                    var tell = $('input[name="tell"]').val();
                    var where = $('input[name="hidden_email"]').val();
                    }

            console.log(aanhef + ' ' + username + ' ' + achternaam + ' ' + adres + ' ' + plaats + ' ' + postcode + ' ' + email + ' ' + tell + ' ' + where);

            $.ajax({
                type: 'post',
                url: 'config/save_profiel.php',
                data: { 'aanhef': aanhef, 'naam': username, 'achternaam': achternaam, 'adres': adres, 'plaats': plaats,  'postcode': postcode, 'email': email, 'tell': tell, 'where': where}
            });



$aanhef = mysqli_real_escape_spring($conn,$_POST['aanhef']);
$name = mysqli_real_escape_spring($conn,$_POST['username']);
$achternaam = mysqli_real_escape_spring($conn,$_POST['achternaam']);
$adres = mysqli_real_escape_spring($conn,$_POST['adres']);
$plaats = mysqli_real_escape_spring($conn,$_POST['plaats']);
$postcode = mysqli_real_escape_spring($conn,$_POST['postcode']);
$email = mysqli_real_escape_spring($conn,$_POST['email']);
$tell = mysqli_real_escape_spring($conn,$_POST['tell']);
$where = mysqli_real_escape_spring($conn,$_POST['where']);
$first = '1';



$updateUser = "UPDATE users SET aanhef='$aanhef', name='$name', last_name='$achternaam', telefoon='$tell', adres='$adres', plaats='$plaats', postcode='$postcode', first_login='$first' WHERE email='$where'";

if ($updateUser) {
    mysqli_query($conn,$updateUser) or die (mysqli_error($conn));
}

1 个答案:

答案 0 :(得分:3)

正如我在上面的评论中所指出的,HTTP 500表示一般的服务器端错误。任何时候你看到它的第一步应该是检查你的日志。

您这样做了,您发现了以下消息:

  

PHP致命错误:在/Applications/MAMP/htdocs/save_profiel.php中调用未定义的函数mysqli_real_escape_spring()

这似乎非常清楚地表明了:你已拼错了mysqli_real_escape_string