我对angular和php相当新。我正在尝试使用angularjs从html页面发布到php页面。帖子成功但是response.data是php文件的纯文本,而不是我回显的json对象。
的test.html
func getBetsFor(_ username: String) {
ref.child("Bets".child(username).observe(.childAdded, with: { snapshot in
//
// this is the unique identifier of the bet. eg, -Kfx81GvUxoHpmmMwJ9P
let betId = snapshot.key as String
guard let dict = snapshot.value as? [String: AnyHashable] else {
print("failed to get dictionary from Bets.\(username)")
return
}
let bet = dict["Bet"] as? String
let forTeam = dict["ForTeam"] as? String
// do something with the above information!
})
}
test.php的
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl" ng-init="LoadPage('kengoss@yahoo.com')">
<p>Welcome Dr. {{last_name}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http)
{
$scope.last_name = 'Summers';
$scope.LoadPage = function($email)
{
$scope.last_name = $email;
$http({
method: "post",
url: "test.php",
data: { email: $email},
headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function mySuccess(response){
$scope.last_name = response.data;
},function myFailure(response){
$scope.last_name = 'Failure';
}
);
}
});
</script>
</body>
</html>
答案 0 :(得分:0)
这有帮助吗?
Folder: \
HostName: pi
TaskName: \Create-snapshot
Next Run Time: 3/27/2017 3:32:00 AM
Status: Running
Logon Mode: Interactive/Background
Last Run Time: 3/27/2017 3:31:02 AM
Last Result: 267009
Author: pi\Administrator
Task To Run: C:\Data\Admin\Create-Snapshot\Create-Snapshot-Start.bat >> "c:\Data\Admin\Create-Snapshot\Log\Create-Snapshot-start 2017-03-27 2_47_25.log"
Start In: N/A
Comment: N/A
Scheduled Task State: Enabled
Idle Time: Disabled
Power Management: Stop On Battery Mode, No Start On Batteries
Run As User: Administrator
Delete Task If Not Rescheduled: Disabled
Stop Task If Runs X Hours and X Mins: 72:00:00
Schedule: Scheduling data is not available in this format.
Schedule Type: One Time Only, Minute
Start Time: 12:56:00 AM
Start Date: 3/27/2017
End Date: N/A
Days: N/A
Months: N/A
Repeat: Every: 0 Hour(s), 1 Minute(s)
Repeat: Until: Time: None
Repeat: Until: Duration: Disabled
Repeat: Stop If Still Running: Disabled