angular event success when submit form it opens popup

a 夏天 提交于 2019-12-05 12:30:02

Does your payTest function execute at all?

I would do it like this:

function testController($scope, $http) {

     $scope.pay = function () {
        $http({
             method: 'POST',
             url: 'http://backend.mysite.com/Order/Create',
             data: JSON.stringify({ $scope.newOrder: 1 })
        })
        ['success'](function (data, status, headers, config) {
            console.log('http success');
            $scope.payTest();
        })
        ['error'](function (data, status, headers, config) {
             console.log('http failure');
        });
    };

    $scope.payTest = function() {

         console.log('paytest is executed!');
        // all your stuff

    }; 

}

UPDATE: I changed the syntax of the $http call to what I always use.

Michele Dibenedetto

Ok, the answer and the explanation to the problem is here Open page in new window without popup blocking

PROBLEM: when I perform form.submit() I get a popup window instead to get a new tab on browser

REASON: I have performed that submiut into a success delegate of ajax calling, that means the user did not start esplicitilly the submit so the browser respond with a popup and with blocked popup if BLOCK IS ON

SOLUTION: we can solve the situation in two way 1) set target ="_self" but we will get the respond of submit into the parent page 2) use a a synchrone flag on ajax calling. Pay attention it seems the angular $http use async requests by hard coded flag

thnak for all of answers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!