我是一個新的Angularjs用戶。我面臨一個問題,當我提交註冊表單時,我已經應用了使用AngularJs進行驗證。同時,如果所有的輸入字段都是有效的,那麼我發送一個$ http Ajax調用來檢查電子郵件地址,已經存在或不存在。問題是我的php文件沒有收到電子郵件數據。使用角度js的Ajax調用
$http({
method : 'POST',
async: false,
url: 'http://localhost/angular/signup/emailcheck.php',
data: { email: $scope.user.email }, // pass in data as strings
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
})
.success(function(data)
{
$scope.info = data;
if($scope.userForm.$valid && $scope.info === '0') {
alert('our form is amazing' + $scope.info);
}
else{
alert('Already exist');
}
}).error(function(response,status)
{
console.log('ERROR HERE'+ status);
});
我的PHP文件中的代碼:
$email = $_POST['email'];
$sql = "SELECT * FROM user where username = '".$email."'";
$result = mysql_query($sql);
//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
....
....
....
....
....
}
我已經檢查,發現PHP文件沒有收到電子郵件價值可言。
檢查控制檯日誌如果你得到一些錯誤? –
在瀏覽器的控制檯中是否有錯誤? – Achu
不,在控制檯沒有任何錯誤,我檢查過它。 –