【发布时间】:2015-06-22 21:22:12
【问题描述】:
首先我调用了 userSignupSubmit 函数。在这个方法中调用另一个方法 mobilenocheckingmethod ,依赖于这个 ajax 调用响应来调用另一个 ajax 调用,但第二次调用它将不起作用。
var crm = angular.module('crm');
crm.controller("userCheckingController", function($scope,service, $http) {
var key="";
$scope.mobilenoCheckingSubmit = function() {
var dataObject="serialNo="+$scope.mobileno;
alert(dataObject);
$http({
method:'POST',
url:'registerDevice',
data:dataObject,
headers:{'Content-Type':'application/x-www-form-urlencoded'}
}).
success(function(data, status, headers, config) {
var code=data.code;
if(code!=200)
{
alert("mobileno200"+data.message);
key=data.clientKey;
this.userSignup();
}
else
{
alert("mobileno201"+data.message);
alert("mobileno201"+data.clientKey);
key=data.clientKey;
this.userSignup();
}
}).
error(function(data, status, headers, config) {
$scope.user_error_status="Inside Error Occur";
return;
}).
//this.userSignup();
}
$scope.userSignupSubmit = function() {
this.mobilenoCheckingSubmit();
}
$scope.userSignup=function(){
var dataObject="email="+$scope.signupEmail+"&key="+key;
alert(dataObject);
$http({
method:'POST',
url:'signUp',
data:dataObject,
headers:{'Content-Type':'application/x-www-form-urlencoded'}
}).
success(function(data, status, headers, config) {
var code=data.code;
if(code === 201)
{
alert(data.message);
}
if(code === 200)
{
alert(data.message);
}
if(code === 409)
{
service.Key(data.Key);
$scope.manual_dashboard = true;
$scope.userChecking = true;
}
}).
error(function(data, status, headers, config) {
$scope.signup_error_status="Inside Error Occur";
});
}
});
【问题讨论】:
-
它给出了什么错误?
标签: javascript ajax angularjs angularjs-http