在ajax请求中使用require_once

时间:2012-03-09 16:16:13

标签: php jquery ajax

我想使用require_once来处理我的ajax请求。但它显示错误。这是我的代码。

 var val = $('#customers option:selected').val();
 $.post('base/chartval.php', {customer:val},  function(data) {

 });

这是我的基础/ chartval.php

<?php

require_once 'service.php';

if (isset($_POST)) {

    $customer = $_POST['customer'];

    echo $customer; 

    $service::getColumData($customer);
}

这是使用require_once时显示的错误。

"NetworkError: 500 Internal Server Error - http://localhost:2500/dinukanew/base/chartval.php"

但是当删除require行时echo $customer;正常工作。

service.php文件也在基础文件夹中。当我删除require_once它可以工作。但我想在service.php中使用方法。请帮我。

1 个答案:

答案 0 :(得分:0)

require_once要求在括号中传递参数:

require_once('service.php')