I have searched for the reason behind this error for the last couple hours unable to solve it. Hopefully someone has experienced the same issue and is able to help with a remedy.
I am using Ionic and Angular to create a simple application. I am running locally using Ionics ionic serve command to set up a simple server.
I have a simple index.html page that is as follows:
...
<body data-ng-controller="AppCtrl">
<ion-header-bar class="bar-balanced">
<h1 class="title ">Hello World!</h1>
</ion-header-bar>
<ion-content>
<h1>Some Content</h1>
</ion-content>
</body>
...
and an app.js file that has been iterated numerous times and tried various online tutorials to end up with:
var App = angular.module("App", ["ionic"]);
App.controller("AppCtrl", ["$scope", "$http" , AppCtrl]);
function AppCtrl($scope, $http) {
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
var request = $http({
method: 'post',
url: 'http://localhost:8100/php/login.php',
data: { "cat" : "henry" },
headers : {"Content-Type": 'application/x-www-form-urlencoded'}
}).success(function (data, status, headers, config) {
console.log(data);
}).error(function (data, status, headers, config) {
console.log("login.php failed");
});
};
My problem: is that I am getting "404 Not Found" error on my post requests. However, when I change to a get request, it seems to echo back the PHP file just fine. Its a simple echo "Hello World!" php file.
At this point, any helpful information would be greatly appreciated. Thank you!