微信页面特殊,无法使用console.log, 只能用alert, 效率低,可以使用 http://jsconsole.com , 将console.log 重定向出来,使用非常简单。
:listen
# 系统会生成一个随机字符串,如
# 将下列代码插入到测试页面的开头,然后就可以愉快地使用 console.log() 了
<script src="https://jsconsole.com/js/remote.js?dcb7ac5a-38a0-46bb-b604-172f6995c9"></script>
# 如果关闭了连接,支持重新连接,使用如下命令
:listen dcb7ac5a-38a0-46bb-b604-172f6995c9
$.ajax({
type: 'GET',
url: '/?mod=weixin&v_mod=shop_order&_index=_list&_action=ActionConfirmReceive&orderid='+orderid,
dataType: 'json', /* 如果下面要使用json格式读取,这里不能省略,否则无法正确读取 */
beforeSend: function(){
console.log('beforeSend');
},
success: function(res)
{
alert(res.msg);
},
error:function(res) {
alert('connected faild');
}
});
以上代码可以用 getJSON 代替,更加简洁
$.getJSON('/?mod=weixin&v_mod=shop_order&_index=_list&_action=ActionConfirmReceive&orderid='+orderid)
.done(function(data){
alert(data.msg); /* 直接当作json对象读取 */
location.href="/?mod=weixin&v_mod=shop_order&_index=_list&orderid="+orderid;
})
.fail(function(){
alert('网络超时,请重试!');
});
<a href="javascript:history.back()">返回</a>
margin: 0 0 2em 0; /* 上、左、右、下 , 逆时针 */
padding: 0.3em 0; /* 上下、左右 */