Javascript Json数据不会显示在使用php文件的angularjs中的html文件中

Javascript Json数据不会显示在使用php文件的angularjs中的html文件中,javascript,android,json,angularjs,express,Javascript,Android,Json,Angularjs,Express,如何在angularJS中设置php文件以设置任何json代码的id 打孔和鞋底这是我的最终代码 <!DOCTYPE html> <html class="no-js" lang="en" ng-app="myBusStopApp"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width

如何在angularJS中设置php文件以设置任何json代码的id

打孔和鞋底这是我的最终代码

<!DOCTYPE html>
    <html class="no-js" lang="en" ng-app="myBusStopApp">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>My bus stop - Real time data</title> 
        <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
        <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">   
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>   
        <script type="text/javascript">     

        angular.module('myBusStopApp', [])
    .controller('myBusStopCtrl', ['$scope', '$http', function ($scope, $http) {
        //$scope.realTimeData;

        var url ="http://192.168.1.10/android_connect/JsonReturn.php";
     //   var url = "http://reis.trafikanten.no/reisrest/realtime/getrealtimedata/3010435" + "?callback=JSON_CALLBACK";
    alert(url); 
        $http.jsonp(url)

            .success(function(data){
                alert(url); 
                $scope.realTimeData = data;
            });

    }]);</script>
    </head>
    <body style="margin-top:2%;font-size:14px;font-family:Open Sans; padding-left:2%;padding-right:2%;">
    <div ng-controller="myBusStopCtrl">
        <center>
        <div class="table-responsive" style="max-width:800px;">
        <table class="table table-striped" >
            <thead>
                <tr class="info">
                <th>Bus#</th>
                <th>Destination</th>
                <th>Wait time</th>          
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="item in realTimeData">
                    <td>{{item.id}}</td>
                    <td>{{item.email}}</td>
                    <td>kk</td>            
                </tr>
            </tbody>
        </table>
    </div>
    </center>
    </div>
    </body>
    </html>

请帮助我摆脱这种情况。如果您返回json数据,请为json添加相关标题

header('Content-Type: application/json');
echo $json;
只需添加:-

    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: *");

    at the top of php page inside
 <?php
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: *");

your code..   

 ?>
标题(“访问控制允许原点:”;
标题(“访问控制允许标题:”;
在php页面的顶部

它允许您启用cors(跨源资源共享)。

chrome错误已得到解决,但数据未显示在html文件中您在
console.log(数据)上获得的内容关于成功的ajax?我在console.log(data)中找不到任何答案;在javascript code.sir K.Toress中,XMLHttpRequest无法加载有一个问题。访问控制允许标头不允许请求标头字段X-Requested-With。在android手机中。。当我在php文件中包含此选项,但在该扩展中启用时的任何答案都会显示正确的答案。我在XMLHttpRequest中遇到问题,无法加载192.168.1.10/android_connect/JsonReturn.php。访问控制允许标头不允许请求标头字段X-Requested-With。在android手机中。。当我在我的php文件中包含这个,但在这个扩展中启用任何答案,然后显示正确的答案我已经在我的php文件中添加了这个,但是错误显示我这个,但是在chrome中显示我错误,但是我已经在安卓手机中运行了这个代码XMLHttpRequest无法加载。访问控制允许标头不允许请求标头字段X-Requested-With。请帮助我摆脱这种情况,我正在使用android应用程序。您的php托管在任何Web服务器上吗。。??或者只是一个简单的文件。。??如果很简单,请在本地的任何服务器上托管它,然后在移动应用程序中上载它时点击localserver上的it.my php文件,然后向我显示{{item.id}这种类型的数据不是原始数据OK这里是最好的链接,请仔细阅读,将$http.jsonp更改为$http.get,然后重试
 XMLHttpRequest cannot load http://192.168.1.10/android_connect/JsonReturn.php. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
header('Content-Type: application/json');
echo $json;
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: *");

    at the top of php page inside
 <?php
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: *");

your code..   

 ?>