我已经看到了Python的答案,但不是PHP。我有两个选择框,一个选择框填充了API调用中的公司列表。当用户选择其中一家公司时,我希望第二个选择框填充该公司的位置。
这是我的app.yaml文件:
application: APP-NAME
version: 150115
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /
script: index.php
secure: always
- url: /favicon\.ico
static_files: ewme/images/favicon.ico
upload: favicon\.ico
- url: /stylesheets
static_dir: ewme/css
application_readable: true
- url: /images
static_dir: ewme/images
application_readable: true
- url: /js
static_dir: ewme/js
application_readable: true
- url: /ajax_request
script: /ewme/scripts/ajax/request.php
- url: /.*
script: index.php
secure: always
我在php文件中的php代码,它呈现了html。
$companies = AjaxRequest::getCompanies();
$companies = json_decode($companies,true);
$cos = array();
foreach ($companies['companies'] as $co) {
$cos[$co['company_code']] = strtoupper($co['company_code']);
}
...呈现的html ......
<td>
<label for="company_code">Company</label>
<select name="company_code" id="company_code" onchange="sendAjax("/ajax_request",new Array("company_code"),"&req=getCompanyLocations");">
</td>
scripts / ajax.request.php文件:
<?php
$_POST['ajax']=true;
require_once('../../../env.php');
$current_user = Auth::getLoggedInUser();
$content="";
if (isset($_REQUEST['req']) && method_exists("AjaxRequest",$_REQUEST['req'])) {
$r=$_REQUEST['req'];
$ar = new AjaxRequest();
$content=$ar->{$r}($_REQUEST);
}
echo $content;
从我的JavaScript函数&#34; sendAjax&#34;我一直收到此错误500 "<br />
<b>Fatal error</b>: Class 'Auth' not found in <b>/Users/Katrina/APP-NAME/ewme/scripts/ajax/request.php</b> on line <b>7</b><br />
" "error" "Internal Server Error"
我尝试单独包含文件,但是我必须基本上包含我项目中的所有文件。我的env.php文件包含我的config.php,它有我的spl_autoload_register();功能,所以我不确定为什么它不起作用?非常感谢任何帮助!