AJAX Post 500内部服务器错误 -

时间:2017-01-26 09:39:28

标签: javascript php jquery ajax internal-server-error

我尝试使用AJAX来更新我的数据库并始终获得内部服务器错误(500)我不确定为什么会发生这种情况,我的数据列表是否太长了?在我的localhost服务器上,它似乎可以工作,但不能在线。

这是我的JS代码:

function update_database() {
  var $1Intro = $('#1Intro').val();
  var $1Perspektive = $('#1Perspektive').val();
  var $1Rahmung = $('#1Rahmung').val();
  var $1Montage = $('#1Montage').val();
  var $2Intro = $('#2Intro').val();
  var $2Handlung = $('#2Handlung').val();
  var $2Perspektive = $('#2Perspektive').val();
  var $2Zeit = $('#2Zeit').val();
  var $3Intro = $('#3Intro').val();
  var $3Zeit = $('#3Zeit').val();
  var $3Spielraum = $('#3Spielraum').val();
  var $3Rolle = $('#3Rolle').val();
  var $3Regeln = $('#3Regeln').val();
  var $3Netzwerk = $('#3Netzwerk').val();
  var $01Done = $('#01Done').val();
  var $02Done = $('#02Done').val();
  var $03Done = $('#03Done').val();
  var $0Intro = $('#0Intro').val();
  var $0Fin = $('#0Fin').val();
  var $Position = $('#Position').val();
  var $MobileUser = $('#MobileUser').val();
  var $usr = $('#User').val();

  $.ajax({
     type: 'POST',
     url: './gameengine/dataform-to-database.php',
     data: '1_Intro=' + $1Intro + '&1_Perspektive=' + $1Perspektive + '&1_Rahmung=' + $1Rahmung + '&1_Montage=' + $1Montage + '&2_Intro=' + $2Intro + '&2_Handlung=' + $2Handlung + '&2_Perspektive=' + $2Perspektive + '&2_Zeit=' + $2Zeit + '&3_Intro=' + $3Intro + '&3_Zeit=' + $3Zeit + '&3_Spielraum=' + $3Spielraum + '&3_Rolle=' + $3Rolle + '&3_Regeln=' + $3Regeln + '&3_Netzwerk=' + $3Netzwerk + '&0_1Done=' + $01Done + '&0_2Done=' + $02Done + '&0_3Done=' + $03Done + '&0_Intro=' + $0Intro + '&0_Fin=' + $0Fin + '&Position=' + $Position + '&usr=' + $usr + '&MobileUser=' + $MobileUser,
     cache: false,
     error: function(e){
      console.log(e);
      },
      success: function(response){
        //alert(response);
      }
  });
}

我希望你有一些想法:)

P.S。:这里也是我的PHP代码:Tnax供您参与!

<?php
require('../includes/config_o.php');

if(isset($_POST["usr"]))
{

    $stmt = $db->prepare('UPDATE userdata SET 1_Intro = :1_Intro, 1_Perspektive = :1_Perspektive, 1_Rahmung = :1_Rahmung, 1_Montage = :1_Montage, 2_Intro = :2_Intro, 2_Handlung = :2_Handlung, 2_Perspektive = :2_Perspektive, 2_Zeit = :2_Zeit, 3_Intro = :3_Intro, 3_Zeit = :3_Zeit, 3_Spielraum = :3_Spielraum, 3_Rolle = :3_Rolle, 3_Regeln = :3_Regeln, 3_Netzwerk = :3_Netzwerk, 0_1Done = :0_1Done, 0_2Done = :0_2Done, 0_3Done = :0_3Done, 0_Intro = :0_Intro, 0_Fin = :0_Fin, Position = :Position, MobileUser = :MobileUser WHERE iUserID = :User');
    $stmt->execute(array(
        ':1_Intro' => $_POST["1_Intro"],
        ':1_Perspektive' => $_POST["1_Perspektive"],
        ':1_Rahmung' => $_POST["1_Rahmung"],
        ':1_Montage' => $_POST["1_Montage"],
        ':2_Intro' => $_POST["2_Intro"],
        ':2_Handlung' => $_POST["2_Handlung"],
        ':2_Perspektive' => $_POST["2_Perspektive"],
        ':2_Zeit' => $_POST["2_Zeit"],
        ':3_Intro' => $_POST["3_Intro"],
        ':3_Zeit' => $_POST["3_Zeit"],
        ':3_Spielraum' => $_POST["3_Spielraum"],
        ':3_Rolle' => $_POST["3_Rolle"],
        ':3_Regeln' => $_POST["3_Regeln"],
        ':3_Netzwerk' => $_POST["3_Netzwerk"],
        ':0_1Done' => $_POST["0_1Done"],
        ':0_2Done' => $_POST["0_2Done"],
        ':0_3Done' => $_POST["0_3Done"],
        ':0_Intro' => $_POST["0_Intro"],
        ':0_Fin' => $_POST["0_Fin"],
        ':Position' => $_POST["Position"],
        ':User' => $_POST["usr"],
        ':MobileUser' => $_POST["MobileUser"]
    ));

}

?>

3 个答案:

答案 0 :(得分:0)

500 - 是服务器错误。

也许你的真实网址没有点?

 url: '/gameengine/dataform-to-database.php',

或者你在php脚本中有错误。然后显示代码

答案 1 :(得分:0)

在您的ajax中:{ur了} s如果您想要前一个文件夹../

还以对象格式发送您的数据。就像这个..

gameengine/dataform-to-database.php

AJAX

data = {$1Intro:$('#1Intro').val(),$1Perspektive:$('#1Perspektive').val(),...so on }

答案 2 :(得分:0)

  

所以我认为我以某种方式通过将我的php版本恢复到5.5来解决它。   不是一个真正的解决方案,但现在它可以工作。

编辑:不是真的...再也不会得到任何错误。仍然没有工作