我正在嘗試使用 angular 和 json 將數據庫中的一些數據顯示到我的 html 頁面,但是即使設法讀取我的數據庫,瀏覽器也不會顯示我的數據。有人可以解釋為什么會這樣嗎?我在這個網站上看了幾個答案,但沒有一個能解決問題,甚至從不同的瀏覽器和從 unix 切換到 Windows。這是我的控制器myApp.controller('postCtrl',function($scope){ $.ajax({ type: 'GET', url: './webservices/post.php', dataType : 'json', success : function(response){ $scope.locali = response.info; $scope.posts = response.info; console.log($scope.locali); }, fail: function(result){ $("#messaggiodierrore").html("query non riuscita! "); } }); console.log($scope.locali);});這是我的 html<div class="col-md-8" ng-controller = "postCtrl"> <table class="table table-hover"> <thead> <tr> <th>Locale </th> <th>Indirizzo</th> <th>città</th> <th>attrezzature</th> </tr> </thead> <tbody > <tr ng-repeat="locale in locali track by $index" > <td>{{locale.nomeLocale}} </td> <td>{{locale.indirizzo}} </td> <td>{{locale.citta}} </td> <td>{{locale.attrezzature}} </td> <td><a class="btn btn-default" href="#!rispondi">Rispondi</a> </td> </tr> </tbody> </table></div>這是我的 php(正在運行)<?phpinclude_once('config.php');$sql= "SELECT * FROM locale";$query = mysqli_query($conn,$sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR);if(mysqli_num_rows($query) > 0){ while($row = mysqli_fetch_assoc($query)){ $locale = $row['NomeLocale']; $indirizzo = $row['indirizzo']; $citta = $row['citta']; $attrezzature = $row['attrezzature']; $result[] = array('nomeLocale'=>$locale, 'indirizzo'=>$indirizzo,'citta'=>$citta,'attrezzature'=>$attrezzature); } 谷歌瀏覽器控制臺發送給我這個:[{"nomeLocale":"asdf","indirizzo":"asdf","citta":"asdf","attrezzature":"0"}]這就是我的數據庫中的內容,但我無法理解為什么這沒有顯示在我的 html 表格中。`
- 1 回答
- 0 關注
- 161 瀏覽
添加回答
舉報
0/150
提交
取消