在ajax PHP函数中包含一个类会导致崩溃

时间:2015-08-09 05:00:20

标签: php jquery ajax

我有一个为特定函数调用ajax.php的ajax函数,当它被调用时,我想要包含一个类,但是当我这样做时,它会导致请求崩溃并返回此错误:< / p>

  

无法加载资源:服务器响应状态为500(内部服务器错误)

这是我的PHP代码:

$ajax_action = _POST('ajax');
if($ajax_action == "gwonline")
{
    $isonlinestr = '<span class="fa fa-circle" style="color:red"></span> Offline';
    $isonline = false;
    include './include/SampQueryAPI.php';
    $server = new SampQueryAPI("37.59.60.13", 7778);
    if(isset($server) && $server->isOnline())
    {
        $sInfo = $server->getInfo();
        $isonline = true;
        if($sInfo != -1)
        {
            if(isset($sInfo['players']) && isset($sInfo['maxplayers']))
            {
                $basicPlayers = $sInfo['players'];
                $maxPlayers = $sInfo['maxplayers'];
            }
            $isonlinestr =  '<span class="fa fa-circle" style="color:green"></span> Online<br>Players Online: ' . issetordefault($basicPlayers, "0") . "/" . issetordefault($maxPlayers, "0");
        }
    }
    $server->__destruct();
    $return = json_encode(array("isonline" => $isonline, "isonlinestr" => $isonlinestr));
    exit($return);
}

当我拨打include时,它会崩溃。我尝试包含./include/SampQueryAPI.php'SampQueryAPI.php./SampQueryAPI.php

ajax.phpSampQueryAPI.php文件夹中,因此它应该是最后一个,但它们都不起作用。这是不可能包含在ajax请求中吗?

0 个答案:

没有答案