$('.productUrl').on('click', function () { var platformId = {!! $order->platformId !!}; if( platformId != 72) { url = $(this).data('href'); }else{ var detailid = $(this).data('detail'); var account = '{!! $order->account->account !!}'; var data = {'detailid':detailid,'account':account}; var tempwindow=window.open(); $.ajax({ url: '{{ url("order/getWalmartProductUrl") }}', data:data, dataType:"json", type: 'post', success: function(data) { if(data.code == 200) { tempwindow.location = data.data; }else{ return false; } } }); } });
先在ajax 外部調用一個打開窗口再賦值連接地址,避免事件被遮擋javascript