view
<ion-view view-title="Dashboard">
<ion-content class="splash padding has-header">
<p class="button button-calm button-block" ng-click="insert()">post</p>
</ion-content>
</ion-view>
controller $scope.insert = function() { var data = {matric:21};
$http.post("http://localhost:8000/datas",data).success(function(data,status){
console.log(data);
}).error(function(error){
console.log("error is that ",error);
});
};
laravel routes
Route::get('datas',array('middleware' => 'cors', 'uses' => 'datasController@index'));
Route::get('datas/{level}',array('middleware' => 'cors', 'uses' => 'datasController@show'));
Route::post('datas',array('middleware' => 'cors', 'uses' => 'datasController@store'));
laravel controller
public function store()
{
$dat = new Data();
$dat->matric = input::get('matric');
$dat->save();
}
the error i get in my chrome log
XMLHttpRequest cannot load
http://localhost:8000/datas. Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'http://evil.com/, *', but only one is allowed. Origin'http://localhost:8100'is therefore not allowed access.controllers.js:126 error is that null
the error i get in my mozilla log
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/datas. (Reason: CORS header 'Access-Control-Allow-Origin' missing). error is that null