javascript - Request to Php file from node js and i am getting the error 404 not found and i tried every possible path but not getting it -
my request code in js file :
$http.post('php/db-r-distinct.php', zd)                 .then(function (response) {                 console.log('constructor, partners response : ' + json.stringify(response.data));                 _this.$scope.dem = response.data; // on récupère ici les données du php              }); my php file placed in folder src/php/db-r-distinct.php
<?php include 'gs.php';  try {     $mysql = new pdo("mysql:dbname=".sql_dbase.";host=".sql_host, sql_user, sql_pass);     $mysql->setattribute( pdo::attr_errmode, pdo::errmode_exception );     $mysql->exec("set character set utf8");      // sets encoding utf-8  } catch (pdoexception $e) {echo 'error :' . $e->getmessage();} $dd = json_decode(file_get_contents("php://input")); $tab = $dd ->tab; $distct = $dd ->distinctv; $sql = "select t1.* $tab t1 join (     select $distct, max(du) latest $tab group $distct ) t2 on t1.$distct = t2.$distct , t1.du = t2.latest order t1.du desc"; $c = array(); $r=$mysql->query($sql); while($row=$r->fetch(pdo::fetch_assoc)) {   $c[]=$row; } $r->closecursor(); exit(json_encode($c)); ?> my folder structure : backendwe/src/php/db-r-distinct.php
my php file run here
'http://localhost/backendwe-master/src/php/db-r-distinct.php' but when adding in request in js file error
so here error path of php file how define path in node environment . how data php file in node js ? node js running on localhost:3000 , php on apache server localhost only
path of project : backendwe/src/php/all php files backendwe/src/index.html backendwe/src/js/all controllers here
you having cors issue.
you can add @ top of each files want request :
<?php header("access-control-allow-origin: *"); or add global configuration apache example.
and post request path must backendwe-master/src/php/db-r-distinct.php rather php/db-r-distinct.php.


Comments
Post a Comment