我是一个新的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
不,在控制台没有任何错误,我检查过它。 –