简体   繁体   English

无法加载资源:服务器的响应状态为405(不允许使用方法)api

[英]Failed to load resource: the server responded with a status of 405 (Method Not Allowed) api

When I run http-server -o with angularjs(frontend) to use api from symfony (backend) for login, I get this error: 当我运行HTTP服务器与symfony的(后端)进行登录angularjs(前端)使用的API -o,我得到这个错误:

Failed to load resource: the server responded with a status of 405 (Method Not Allowed) :8080/app/api/src/AppBundle/Controller/MainController.php 无法加载资源:服务器的响应状态为405(不允许使用方法):8080 / app / api / src / AppBundle / Controller / MainController.php

error Impossible d'accéder au serveur. error不可能的服务。

connection.js connection.js

'use strict';
    angular.module('myapplication.connection', ['ngRoute'])
    .config(['$routeProvider', function($routeProvider) {
      $routeProvider.when('/connection', {
        templateUrl: 'connection/connection.html',
        controller: 'connectionCtrl'
      });}])
    .controller('connectionCtrl', ['$http', '$scope', function($http, $scope) {
        $http.post('api/src/AppBundle/Controller/MainController.php', {formType:'connection'})
    .then(function (response) {
            $scope.connection = response.data;
        }, function(response) {
            $scope.connection = "Impossible d'accéder au serveur.";
        }); 
    }]);

connection.html(form) connection.html(form)

<div class="content">
    <h2>Connexion</h2>
    <div>{{ connection }}</div>
</div>

How do I solve this error? 我该如何解决这个错误?

The backend likely requires you to set Content-Type and/or Accept in your request header. 后端可能需要您在请求标头中设置Content-Type和/或Accept。 See here for example. 例如参见这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载资源失败:服务器响应状态为 405(方法不允许)angularjs - Failed to load resource: the server responded with a status of 405 (Method Not Allowed) angularjs 上载图像AngularJS未能加载资源:服务器的响应状态为405(不允许使用方法) - Uploading an image, AngularJS, Failed to load resource: the server responded with a status of 405 (Method Not Allowed) 无法加载资源:服务器响应从Angularjs到WebApi的状态为405(方法不允许) - Failed to load resource: the server responded with a status of 405 (Method Not Allowed) from Angularjs to WebApi Web API-无法加载资源:服务器响应状态为404 - Web API - Failed to load resource: the server responded with a status of 404 加载资源失败:服务器响应状态为415 - Failed to load resource: the server responded with a status of 415 加载资源失败:服务器响应状态为500(内部服务器错误 - Failed to load resource: the server responded with a status of 500 (Internal Server Error Google-map API给出无法加载资源:服务器的响应状态为403() - Google-map API giving Failed to load resource: the server responded with a status of 403 () AngularJS-$ http加载资源失败:服务器响应状态为404 - AngularJS - $http Failed to load resource: the server responded with a status of 404 Angular.js库无法加载资源:服务器响应状态为404(未找到) - Angularjs libs Failed to load resource: the server responded with a status of 404 (Not Found) 无法加载资源:服务器响应状态为 403(禁止访问)MVC 5 - Failed to load resource: the server responded with a status of 403 (Forbidden) MVC 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM