【发布时间】:2015-09-01 10:04:19
【问题描述】:
我正在尝试在 Google App Engine 上使用 AJAX 请求。 在我的开发环境中,一切正常,我的请求被正确解释。但是当我在生产中更新我的代码时,AJAX 请求的呈现是我的 php 文件中的代码(预期为 json)。就好像代码被解释为纯文本,而不是像 php。 这是我的脚本:
App.yaml 文件:
application: app-name
version: 1
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
application_readable: true
- url: /web/css
static_dir: web/css
- url: /web/js
static_dir: web/js
- url: /web/img
static_dir: web/img
- url: /web/fonts
static_dir: web/fonts
- url: /
script: index.php
- url: /add/update
script: /service/formService.php
- url: /delete
script: /service/deleteFormService.php
- url: /ajax/init
script: web/js/ajax/init.php
- url: /ajax/suiviEtudes
script: web/js/ajax/suiviEtudes.php
- url: /ajax/refreshProjectsPosition
script: web/js/ajax/refreshProjectsPosition.php
Javascript 文件:
function initProjects(){
$.ajax({ url: 'web/js/ajax/init.php',
type: 'post',
success: function(output) {
alert(output);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest.status);
console.log(errorThrown);
}
});
}
我的 php 文件:
<?php
require_once('../../../dao/dao.php');
include('../../../service/baseService.php');
include('../../../service/TownEPCIService.php');
include('../../../service/ContextService.php');
include('../../../service/LinkService.php');
$objProject = new project();
$baseService = new baseService();
$contextService = new contextService();
$linkService = new LinkService();
$townEPCIService = new TownEPCIService();
$project = $objProject->getAll();
$towns = $townEPCIService->getTownsByProjects($project);
$urbanismRules = $baseService->getUrbanismRule();
$ficabilityTypes = $baseService->getFiscabilityType();
$deliberations = $townEPCIService->getDeliberations();
$epcis = $townEPCIService->getEpciByProjects($project);
$studies = $baseService->getStudiesByProject($project);
$themes = $baseService->getThemes();
$states = $baseService->getStatesLabels();
$siteCaracteristics = $contextService->getCaracSiteByProject($project);
$indicators = $baseService->getIndicators();
$consultations = $contextService->getConsultationsByProject($project);
echo json_encode(['projets' => $project,
'towns' => $towns,
'urbanismRules' => $urbanismRules,
'ficabilityTypes' => $ficabilityTypes,
'deliberations' => $deliberations,
'epcis' => $epcis,
'etudes' => $studies,
'themes' => $themes,
'states' => $states,
'siteCaracteristics' => $siteCaracteristics,
'indicators' => $indicators,
'consultations' => $consultations]);
感谢您的帮助。
【问题讨论】:
标签: javascript php jquery ajax google-app-engine