Forum

Problem with AngularJS Ajax http call

Anyone who knows AngularJS AJAX HTTP calls, please look over my code. I am stuck in a problem. I tried very hard but couldn't figure it out.

SCRIPT ON VIEW PAGE

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
var app = angular.module('routes', []);
app.controller('routeCtrl', function($scope, $http)
{
        $scope.route={};
        $scope.submit = function()
        {
            $http.get("checkRoutes").success(function(response) 
            {
                $scope.successCheck = response.message;
            });
        }
</script>

CODING IN LARAVEL CONTROLLER FILE

$input = json_decode( file_get_contents("php://input") );
        $q=DB::select("SELECT * FROM route where PlateNumber='$input->plate'");
        if($q->rowCount()>0)
            echo "Already exists".
        $data["message"] = "Route already exists";
        echo json_encode($data);
haiderali2017
haiderali2017
  • 1 week ago