Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs2 http ajax call returning complete php code

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 enter image description here

I need to get the object of that php array.

Am running the project using "npm start" command.

like image 953
Amruth Avatar asked Aug 01 '26 18:08

Amruth


1 Answers

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

like image 96
Elias Platek Avatar answered Aug 03 '26 08:08

Elias Platek