获取图片之前,先把获取上一张图片的ajax请求取消
Showing
1 changed file
with
8 additions
and
2 deletions
@@ -14,7 +14,8 @@ var $goodsContainer = $('.goods-container'), | @@ -14,7 +14,8 @@ var $goodsContainer = $('.goods-container'), | ||
14 | $goodInfoMain = $goodsContainer.find('.good-info-main'), | 14 | $goodInfoMain = $goodsContainer.find('.good-info-main'), |
15 | $goodSelectColor = $goodsContainer.find('.good-select-color'), | 15 | $goodSelectColor = $goodsContainer.find('.good-select-color'), |
16 | $productListNav = $('.product-list-nav'), | 16 | $productListNav = $('.product-list-nav'), |
17 | - productList; | 17 | + productList, |
18 | + getProductAjax; | ||
18 | 19 | ||
19 | lazyLoad($('img.lazy')); | 20 | lazyLoad($('img.lazy')); |
20 | 21 | ||
@@ -95,7 +96,12 @@ exports.init = function(num) { | @@ -95,7 +96,12 @@ exports.init = function(num) { | ||
95 | wrapperPt, //鼠标移入时弹层的上内边距 | 96 | wrapperPt, //鼠标移入时弹层的上内边距 |
96 | containerPt; //商品列表容器的上内边距 | 97 | containerPt; //商品列表容器的上内边距 |
97 | 98 | ||
98 | - $.ajax({ | 99 | + // 获取图片之前,先把获取上一张图片的ajax请求取消。 网络差的时候会出现错误 |
100 | + if (getProductAjax) { | ||
101 | + getProductAjax.abort(); | ||
102 | + } | ||
103 | + | ||
104 | + getProductAjax = $.ajax({ | ||
99 | type: 'POST', | 105 | type: 'POST', |
100 | url: '/product/list/getProductPic', | 106 | url: '/product/list/getProductPic', |
101 | dataType: 'json', | 107 | dataType: 'json', |
-
Please register or login to post a comment