In Angular project reference to php script give 404 (Not Found) locally, but works on live site

421 views Asked by At

I'm new to Angular and I'm using Yeoman for scaffolding and Grunt for builds. I'm attempting a post to a php script with the following code:

 $http({
  method  : 'POST',
  url     : '/components/contact/test.php',
  data    : $.param($scope.user),  // pass in data as strings
  headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  // set the headers so angular passing info as form data (not request payload)
 });

When I run this on my local server I get the following error

POST http://localhost:9000/components/contact/test.php 404 (Not Found)

How ever when I do a build and push to my web site it does find the php script (I have checked and it is there locally). I tried a number of different variations on the file path and none seem to work. Can anyone explain what's going on here?

0

There are 0 answers