私は何かを見逃しているに違いない...私は本当にこれのノブです。AngularJS to Mysql
は、私は、これはデータangularjs持っている:
$scope.todoList = [
{ text: 'Check me out' },
{ text: 'Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro' },
{ text: 'Ex has semper alterum, expetenda dignissim' },
];
そして、私が代わりにmysqlのテーブルに入れたかったです。私は、テーブルを作成して、テーブルのデータを取得しようとした:
JSを:
$http({method:'POST',url:'process.php'})
.then(
function successCallback(response) { $scope.todoList = response.data;},
function errorCallback(response) {$scope.todoList = "ERROR!";});
PHP:私は手動でPHPをしようとすると
$sql = "SELECT * from `todolist`";
$result = $conn->query($sql);
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
$data[] = array("text" => $row['text']);
}
echo json_encode($data);
出力は次のとおりです。
[{"text":"Check me out"},{"text":"Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro"},{"text":"Ex has semper alterum, expetenda dignissim"}]
誰かが問題の原因を知っていますか?
あなたの問題は何ですか? –
あなたの応答データ型は[valid json data type]ではありません(http://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type)、 ' $ scope.todoList'; 'JSON.parse(response.data)'を使う – MohaMad