angular.js - angularjs $http.post 后 不跳转

查看:174
本文介绍了angular.js - angularjs $http.post 后 不跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

非常菜鸟级别的一个问题哈:

为了接入支付宝的即时到账接口,demo给的例子是:

<form name=alipayment action=alipayapi.php method=post target="_blank">
        <button class="new-btn-login" type="submit" style="text-align:center;">确 认</button>
    </form>

我使用$http的post()方法向alipayapi.php提交post请求:



$scope.goPay=function(){
        $http({
            method : 'POST',
            //url : 'php/submitOrder.php',
            url : 'php/secback/alipay/alipayapi.php',
            data : $.param({ 'oid' : $stateParams.oid,'checkmethod': $scope.checkmethod}),
            headers : { 'Content-Type' : 'application/x-www-form-urlencoded' }
        }).success(function(data) {
            console.log(data);
        });
    };

alipayapi.php实际上会拼接一个html,这个html包含一个表单并且会自动提交。问题是,官方的demo是会自动跳转到支付宝网关,但使用$http的post()方法就不会跳转....
附,console.log(data)的信息:

其实我觉得我就是要一个方法,能把后来传回来的HTML执行一遍就行了....直接eval()貌似不行

解决方案

ajax POST提交的表单不能自动跳,用form+新窗口吧

这篇关于angular.js - angularjs $http.post 后 不跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆