私はangularjsとlaravel 4でアプリケーションを構築しています。 すべては問題ありませんが、今はXHR要求のみを許可する必要があります。Laravel angularjs Request :: ajax()always false
これは私がコントローラの初めに持っていたものです。 しかし、このステートメントは常にfalseです。
if (!\Request::ajax())
{
return Response::json(array('halt'=>Request::ajax()));
};
私は標準的な$ httpサービスを使用しています。
angular.module('APP')
.factory("API", ($http,$q,appClient,apiURL) ->
class FB
constructor:->
this.deferredData = $q.defer();
info: (reload)->
$http(
method: "get"
url: apiURL+'game/'+appClient+"/info"
).success((res)->
dostuff()
)
[この答えをチェックしてください](http://stackoverflow.com/questions/20166320/laravel-4- ajax-check-to-include-xmlhttprequest-magnific-popup/20167599#20167599)。 –
通常、AJAX呼び出しを行うとき、ほとんどのブラウザでヘッダが設定されます: 'X-Requested-With:XMLHTTPRequest'。ブラウザのインスペクタのヘッダが見えますか? – SuperSaiyan
ありがとうございます: '$ httpProvider.defaults.headers.common [" X-Requested-With "] =" XMLHttpRequest "' – zajca