I am new to ionic and I prefer to use ionic v1 instead of v2 or above. Now, I downloaded the ionic files through CLI. And I installed it on my drive d:. And I am starting to make a sample project with blank template. While coding, I am trying to send datas to my php file and it gives me an error of http://localhost:8100/send.php 404 Not Found. I try to put my PHP File Outside of www/ folder and inside and still error exist. Why? I already searched a lot of stuffs regarding on this matter but, I don't understand them. Here;s my code:
$scope.send = function(){
$http.post('send.php',{
'name': $scope.name
}).then(function(response){
// msg
});
}
I hope somebody can help me regarding with my issue. Thanks in advance!
By the way, here's my folder structure:
Drive D > CORDOVA > sample_proj > myapp > www > index.html, send.php
PHP
<?php
if(isset($_SERVER['HTTP_ORIGIN'])){
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400') // cache for 1 day
}
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
if(isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if(isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
$data = json_decode(file_get_contents("php://input"));
if(!$data){
echo "Not called properly";
}else{
echo $data->name;
}
?>