ecshop支付成功后 异步查询订单状态跳转

控制器方法:

if($_REQUEST['act'] == '方法名'){
    include('includes/cls_json.php');
    $json   = new JSON;
    $tradeno = isset($_GET['tradeno']) ? intval($_GET['tradeno']) : 0; 
    $pay_status = $GLOBALS['db']->getOne("select pay_status from ".$GLOBALS['ecs']->table('order_info')." where order_sn='$tradeno'");
    die($json->encode(Array('state'=>$pay_status,'value'=>'')));
}

done订单提交页面:

<script type="text/javascript">
        $(document).ready(function () {
            setInterval("ajaxstatus()", 3000); 
        }); 
        function ajaxstatus() {
            if ($("#out_trade_no").val() != 0) { 
                $.ajax({ 
                    url: "控制器.php?act=方法名&tradeno=" + $("#out_trade_no").val(), 
                    type: "GET", 
                    dataType:"json", 
                    data: "", 
                    success: function (data) { 
                        //alert(data); 
                        if (data.state == 2) {  
                            window.location.href = "user.php?act=order_list"; //页面跳转 
                        }
                    }/*, error: function () { 
                        layer.alert('请求订单状态出错');
                    } */
                }); 
            } 
        } 
  script>

你可能感兴趣的:(php,ecshop)