【发布时间】:2018-08-20 07:06:41
【问题描述】:
我创建了一个 asp.net api 应用程序,它从 JSON 文件中读取数据并将其显示在表格中。当我从 Visual Studio 运行它时,它成功读取数据并显示它,但在我上传到 Azure 后,表是空的。
我将它存储在“jsondata”文件夹中,调用是这样的:
var request = {
method: 'get',
url: '../jsondata/data.json',
dataType: 'json',
contentType: "application/json"
};
头:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
身体:
<div ng-app="myApp"
ng-controller="myController">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>ID</th>
<th>Furniture Piece</th>
<th>Category</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="furniture in list">
<td>{{furniture.ID}}</td>
<td>{{furniture.Name}}</td>
<td>{{furniture.Type}}</td>
<td>{{furniture.Price}}</td>
</tr>
</tbody>
</table>
</div>
使用angular读取json文件的脚本:
<script>
var app = angular.module('myApp', []);
app.controller('myController',
function ($scope, $http) {
var request = {
method: 'get',
url: '../jsondata/data.json',
dataType: 'json',
contentType: "application/json"
};
$scope.arrFurniture = new Array;
$http(request)
.success(function (jsonData) {
$scope.arrFurniture = jsonData;
$scope.list = $scope.arrFurniture;
})
.error(function () {
});
});
</script>
【问题讨论】:
-
请提供更多详细信息,以便我们提供帮助
-
按 F12 并读取错误。
标签: asp.net json api azure web