I'm using AngularJs and php, I've created a php file that returns Json format, but when it comes to reading it from my js file, the output is the php code !
The server works fine with php and the php file is exectuded perfectlly and return json format but when i call it in the app the output is my php text witch meens that the php file is reeded as a text.
What should I do to make it readable as json ?
This is my anjularJs call:
$http.get( './templates/connect.php').success(
function(data){
$scope.cityes=data;
alert($scope.cityes);
});
And this is my php file:
$qry = mysql_query('SELECT capital from countries');
$emparray = array();
while ($rows = mysql_fetch_array($qry)) {
$emparray[] = $rows;
}
header('Content-type:application/json;charset=utf-8');
echo json_encode($emparray);
successfunction ? Did you try withalertorconsole.log?$.getJSON('<host>', function (data) { console.log(data); });or use $.ajax standard with specifying the dataType, I always use $.ajax although you write more you have more control. Cheers