Am making http ajax call to local php file but it's echoing complete php code, am new to angularjs2. can someone help me please.
Here is my angularjs2 code.
makeHttpCall():Promise<any>{
return this.http.get(this.sampleUrl, {headers : this.headers}).toPromise().then((response){
console.log (response)
}).catch(this.handleError);
}
Here is my php code
<?php
$arr = array('name'=>'Dr.Nayana');
echo json_encode($arr);?>
Here is my log

I need to get the object of that php array.
Am running the project using "npm start" command.
It seems like your server is not configured to handle php files properly. The request should return the processed php file, instead it is returned as a simple text file.
you should use a web server like apache with the php module correctly configured:
http://php.net/manual/en/install.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With