Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 取决于angularjs中的一个ajax调用响应调用和另一个ajax调用_Javascript_Ajax_Angularjs_Angularjs Http - Fatal编程技术网

Javascript 取决于angularjs中的一个ajax调用响应调用和另一个ajax调用

Javascript 取决于angularjs中的一个ajax调用响应调用和另一个ajax调用,javascript,ajax,angularjs,angularjs-http,Javascript,Ajax,Angularjs,Angularjs Http,首先我调用了userSignupSubmit函数。在这个方法中调用另一个方法mobilenocheckingmethod,依赖于这个ajax调用响应调用另一个ajax调用,但第二个调用将不起作用 var crm = angular.module('crm'); crm.controller("userCheckingController", function($scope,service, $http) { var key=""; $scope.mobile

首先我调用了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";

            });

       }
    });

您的代码应该使用
$scope.userSignup()
而不是
this.userSignup()它将在ajax调用成功时调用您的scope方法

代码

success(function(data, status, headers, config) {
    var code = data.code;

    if (code != 200) {
        alert("mobileno200" + data.message);
        key = data.clientKey;

        $scope.userSignup(); //<-- change here
    } else {
        alert("mobileno201" + data.message);
        alert("mobileno201" + data.clientKey);
        key = data.clientKey;
        $scope.userSignup(); //<-- change here

    }
})
success(函数(数据、状态、标题、配置){
var代码=data.code;
如果(代码!=200){
警报(“mobileno200”+数据信息);
key=data.clientKey;

$scope.userSignup();//它给出了什么错误?