帮助,我有POST和或PUT方法400错误,但GET工作得很好, 我使用angular作为前端和laravel作为API,我的服务器使用nginx, 我已经使用CORS和我一切工作正常我的当地流浪者是在Apache上运行。角laravel nginx 400错误的请求
我敢肯定,我有我的路线设置正确,这里是它的一些我用的模块:
Route::group(array('prefix'=>'/api', 'middleware' => 'cors'),function(){
Route::post('/create_level', '[email protected]');
Route::get('/read_level', '[email protected]');
Route::get('/read_level/{id}', '[email protected]');
Route::put('/read_level/{id}', '[email protected]');
Route::delete('/read_level/{id}', '[email protected]');
这里是我的角度服务的一部分:
app.service("edulevelService", function ($http, $q, $rootScope)
{
edu.updateEdulevel = function(id, edu){
var deferred = $q.defer();
$http.put($rootScope.endPoint + 'read_level/'+ id, edu)
.success(function(res)
{
deferred.resolve(res);
})
.error(function(err, stat){
deferred.reject(err);
console.log('error code: Ser-UEDU');
});
return deferred.promise;
}
edu.createEdulevel = function(edu){
var deferred = $q.defer();
$http.post($rootScope.endPoint + 'create_level', edu)
.success(function(res)
{
deferred.resolve(res);
})
.error(function(err, stat){
deferred.reject(err);
console.log('error code: Ser-CEDU');
});
return deferred.promise;
}
....
哦,我忘了提到不同的方法导致不同的错误代码POST原因405,PUT导致400,并且我尝试使用邮差: POST正在使用文本类型并返回405使用应用程序/ json, 但是当我尝试 PUT方法甚至虽然它返回200我只得到NULL数据进入到我的分贝(文本类型),如果我使用的应用程序/ JSON其返回400
请帮助
错误信息除坏请求外还有什么? – ssuhat
没有,哦,我忘了提及不同的方法导致不同的错误代码POST导致405,PUT导致400,我试过使用函数回声“...”;在PHP控制器中,它没有被调用,但它在router.php上被调用 – Michael