Internet Explorer没有't通过Ajax连接JSON

Internet Explorer doesn't connect JSON via Ajax

本文关键字:通过 Ajax 连接 JSON Explorer 没有 Internet      更新时间:2023-09-26

我正在SharePoint 2010 Web部件上处理一个动态表,该表由JSON数据提供,从url调用。这在Chrome上是成功的。当我尝试在InternetExplorer10上打印相同的数据时,数据总是一个带有标题的表和一行,其中包含{{items.domain}}、{{items.project}和所有其他数据,因为它无法连接到我的Ajax连接上的url。

是IE故障还是我的代码有问题?

提前谢谢!

<!DOCTYPE html>
<html ng-app="tableJson">
<head>
<script src="/sites/JqueryDemo/JS/jquery-1.11.1.min.js"></script> 
<link href="/sites/JqueryDemo/JS/bootstrap.min.css"></link>
<script src="/sites/JqueryDemo/JS/angular.min.js"></script>
</head>
<body>
<div ng-controller="tableJsonCtrl">
<table border="1" cellpadding="10">
    <tr>
      <td>domain</td>
      <td>project</td>
      <td>username</td>
      <td>host</td>
      <td>Login_time</td>
      <td>Last action</td>
      <td>client_type</td>
    </tr>
    <tr ng-repeat="items in phones">
      <td>{{items.domain}}</td>
      <td>{{items.project}}</td>
      <td>{{items.username}}</td>
      <td>{{items.host}}</td>
      <td>{{items.Login_time}}</td>
      <td>{{items.Last_action}}</td>
      <td>{{items.client_type}}</td>
    </tr>
</table>
</div>
 <script>
var jsonTable
var json = (function () {
    $.ajax({
        'async': false,
        'global': false,
        'url': "http://myurl:8080/users",
        'dataType': "json",
        'success': function (data) {        
            jsonTable = data;   
        }
    });
})();
    var tableJson =  angular.module('tableJson', []);
    tableJson.controller('tableJsonCtrl', function($scope){
    $scope.phones = jsonTable;
    }) 
</script> 
<script src="/sites/JqueryDemo/JS/bootstrap.min.js"></script>
</body>
</html>

不熟悉角度代码。

基本经验法则是jQuery代码应该封装在就绪函数中。请将你所有的JS代码移到里面准备好并尝试。