nie*_*lsv 1 php ajax routes symfony silex
我在服务器上遇到ajax调用问题.这是我的完整routes.php文件:
<?php
$app->post('translations/get/trans', 'Translations\Controller\IndexController::ajaxGetTagsTranslations')->bind('translations.gettrans');
$app->get('/{_locale}/dashboard', 'Dashboard\Controller\IndexController::indexAction')->bind('dashboard.index');
$app->match('/api/todo/{user}/{accessKey}', 'Api\Controller\IndexController::todoAction')->method('POST|GET');
$app->match('/api/getdailymessage/{user}/{accessKey}', 'Api\Controller\IndexController::getDailyMessageAction')->method('POST|GET');
$app->match('/api/todo/out', 'Api\Controller\IndexController::todooutAction')->method('POST|GET');
$app->match('/api/finisharea', 'Api\Controller\IndexController::finishAreaAction')->method('POST|GET');
$app->match('/api/activity', 'Api\Controller\IndexController::activityAction')->method('POST|GET');
$app->match('/api/supplier', 'Api\Controller\IndexController::suppliersAction')->method('POST|GET');
$app->match('/api/translations', 'Api\Controller\IndexController::translationsAction')->method('POST|GET');
$app->match('/api/serverdatetime', 'Api\Controller\IndexController::serverDateTimeAction')->method('POST|GET');
$app->match('/api/dailymessage', 'Api\Controller\IndexController::dailyMessageAction')->method('POST|GET');
$app->match('/api/settings', 'Api\Controller\IndexController::settingsAction')->method('POST|GET');
$app->match('/api/providedby', 'Api\Controller\IndexController::providedByAction')->method('POST|GET');
$app->match('/api/presentations', 'Api\Controller\IndexController::presentationsAction')->method('POST|GET');
$app->match('/api/login', 'Api\Controller\IndexController::loginAction')->method('POST|OPTIONS|HEAD|GET');
$app->get('/{_locale}/hosts/list', 'Hostess\Controller\IndexController::listAction')->bind('hosts.list');
$app->match('/{_locale}/hosts/detail/{id}/{range}', 'Hostess\Controller\IndexController::detailAction')->method('GET')->bind('hosts.detail');
$app->match('/{_locale}/hosts/edit/{id}', 'Hostess\Controller\IndexController::editAction')->method('GET|POST')->bind('hosts.edit');
$app->post('/hosts/gethosts', 'Hostess\Controller\IndexController::ajaxGetHosts')->bind('hosts.gethosts');
$app->get('/{_locale}/segments/list', 'Segments\Controller\IndexController::listAction')->bind('segments.list');
$app->get('/{_locale}/segments/view/{id}', 'Segments\Controller\IndexController::viewAction')->bind('segments.view');
$app->match('/{_locale}/segments/edit/{id}', 'Segments\Controller\IndexController::editAction')->method('GET|POST')->bind('segments.edit');
$app->post('/segments/order', 'Segments\Controller\IndexController::ajaxUpdateOrderAction')->bind('segments.order');
$app->post('/segments/getsegments', 'Segments\Controller\IndexController::ajaxGetSegments')->bind('segments.getsegments');
$app->post('/segments/gethosts', 'Segments\Controller\IndexController::ajaxGetHostsSegment')->bind('segments.gethosts');
$app->post('/segments/updatehosts', 'Segments\Controller\IndexController::ajaxUpdateHostsSegment')->bind('segments.updatehosts');
$app->match('/{_locale}/subarea/edit/{segmentcode}/{deelgebied}', 'Segments\Controller\IndexController::editSubareaAction')->method('GET|POST')->bind('subarea.edit');
$app->get('/{_locale}/presentations/list', 'Presentations\Controller\IndexController::listAction')->bind('presentations.list');
$app->match('/{_locale}/presentations/upload', 'Presentations\Controller\IndexController::uploadAction')->method('GET|POST')->bind('presentations.upload');
$app->post('/presentations/deletepresentation', 'Presentations\Controller\IndexController::ajaxDeletePresentation')->bind('presentations.deletepresentation');
$app->match('/{_locale}/translations/list', 'Translations\Controller\IndexController::listAction')->method('GET|POST')->bind('translations.list');
$app->get('/translations/inserttrans', 'Translations\Controller\IndexController::insertTransJSON')->bind('translations.inserttrans');
$app->match('/{_locale}/settings/list', 'Settings\Controller\IndexController::listAction')->method('GET|POST')->bind('settings.list');
$app->match('/{_locale}/history/index', 'History\Controller\IndexController::indexAction')->method('GET|POST')->bind('history.index');
$app->get('/404', 'Api\Controller\IndexController::indexAction');
Run Code Online (Sandbox Code Playgroud)
我遇到了第一条路线的问题.我首先得到的是以下内容:translations/gettrans但这不起作用.所以现在我尝试了,translations/get/trans但也没有这样做.我总是得到404错误(未找到).当我检查路由时,他可以找到路线:
但为什么这不起作用?