微信PC端扫码支付没有监听状态js,自己整了一个,5秒获取一次订单状态,如果支付成功自动跳转
- <script type="text/javascript">
- $(document).ready(function () {
- setInterval("ajaxstatus()", 5000);
- });
- //$("#HidOrderid").val() 为订单号码
- function ajaxstatus() {
- if ($("#HidOrderid").val() != 0) {
- var HidOrderid = $("#HidOrderid").val().trim();
- //alert(HidOrderid);
- $.ajax({
- url: "<?php echo site_url('web/wxpay/GetOrderStatus')?>",//调用ashx获得订单状态
- data:{
- mobileNo:HidOrderid
- },
- dataType:"html",
- type:"POST",
- success: function (json) {
- json = eval('('+json+')');
- if (json.Satues ==1) { //订单状态为1表示支付成功
- window.location.href = "<?php echo site_url('web/wxpay/payok')?>"; //页面跳转
- }
- },
- error: function () {
- alert("O No~~~");
- }
- });
- }
- }
- </script>
复制代码
|