以下的html代碼: - ` AngularJS | $ HTTP服務器 將用戶輸入的數據保存到文件
<div ng-controller="people">
<ul>
<h2> Names and Ages of progrmmers: </h2>
<li ng-repeat="person in persons">
{{person.Name + ':' + person.Age}}
</li>
</ul>
</div>
的JS文件如下:
var app=angular.module('mainApp',[]);
app.controller('people',function($scope,$http){
$http({
method: 'POST',
url: 'http://localhost/AngularJS/post.json',
data:{"Name": "1234", "Age":"13","Fav_Color":"black"},
headers:{'records':'json'}
})
.success(function(response){
$scope.persons=response.records;
});
});
我需要被保存在一個文件名 「post.json」 的數據。但它不起作用。所以任何人都可以知道我的代碼有什麼問題。
什麼是服務器端的代碼來處理URLS'的「http://本地主機/ AngularJS /後.json'' –
這是post,json文件位於我的電腦中的url – user7339499
這是一個PHP腳本嗎? (奇怪的名字)我認爲你需要做一些關於HTTP –