2
正確,所以我有一個角色功能,使用http方法將數據發送到php文件。php代碼我想處理數據並將其回顯到頁面上確認php文件已經處理了它。我目前正在收到未定義的警告,我當然應該將電子郵件的重要性回饋給我。感謝所有使用angular.js發送數據到一個php文件
我下面這個教程https://codeforgeek.com/2014/07/angular-post-request-php/
var request = $http({
method: "post",
url: "functions.php",
data: {
email: $scope.email,
pass: $scope.password
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
//.then occurs once post request has happened
//success callback
request.success(function (response) {
alert(response.data);
},
//error callback
function errorCallback(response) {
// $scope.message = "Sorry, something went wrong";
alert('error');
});
我的PHP代碼...
//receive data from AJAX request and decode
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
@$email = $request->email;
@$pass = $request->pass;
echo $email; //this will go back under "data" of angular call.
感謝您的幫助:) – Ryan