移动safari崩溃与ajax调用

时间:2015-04-30 14:40:49

标签: javascript jquery ios ajax wordpress

你好,我有网站,我正在加载带有ajax的滑块,它在桌面和Android上工作得非常好,但在加载第二排滑块后,IOS Iphone上的Safari崩溃了。我的代码中有任何错误吗?什么可能导致我的错误?

我正在使用wordpress自定义查询,并在页面上显示2个自定义类型的1个滑块。这是我的html markup 我想补充说滑块有大图片。

    currentPage = 2;
containerItemSelector = ".home-row";
postItemSelector = ".left-col";
containerItemSelector2 = ".home-row";
postItemSelector2 = ".right-col";
counter = 1;
allow = true;
$(window).scroll(function() {
  if(allow && $(window).scrollTop() + $(window).height() > $(document).height()-100) {
    allow = false;
    $.ajax({
      type: "GET",
      url: "<?php echo $_SERVER["REQUEST_URI"] ?>?paged=" + currentPage,
      data: "",
      success: function(results) {
        var item = $(containerItemSelector + " > " + postItemSelector, results);
        item.each(function(i) {
          $(containerItemSelector).append($(this));
          $(this).find('.description').fadeIn(500);
          var slider = $(this).find('.slider-left').attr('id');
          jssor_slider_left.push(new $JssorSlider$(slider, options1));
          var total = jssor_slider_left.length - 1;
          var parentWidth = jssor_slider_left[total].$Elmt.parentNode.clientWidth;

            if (parentWidth)
                jssor_slider_left[total].$ScaleWidth(Math.min(parentWidth,954));
            else
                window.setTimeout(scales, 30);
            $(this).find('.img-wrap2').fadeOut(1500, function(){
                $(this).remove();
            });
            if(counter % 2 == 0){
                $(this).closest('.right-col').after("<div class='clearfix'> </div>");

        }
        counter++;
        });
            var item1 = $(containerItemSelector2 + " > " + postItemSelector2, results);
        item1.each(function(i) {
          $(containerItemSelector2).append($(this));
          $(this).find('.description').fadeIn(500);
          var slider2 = $(this).find('.slider-right').attr('id');
          jssor_slider_right.push(new $JssorSlider$(slider2, options1));
          var total1 = jssor_slider_right.length - 1;
          var parentWidth1 = jssor_slider_right[total1].$Elmt.parentNode.clientWidth;
            if (parentWidth1)
                jssor_slider_right[total1].$ScaleWidth(Math.min(parentWidth1,954));
            else
                window.setTimeout(scales, 30);

            $(this).find('.img-wrap2').fadeOut(1500, function(){
                $(this).remove();
            });
            if(counter % 2 == 0){
                $(this).closest('.right-col').after("<div class='clearfix'> </div>");

        }
        counter++;


        });

       currentPage++;
       allow = true;
      },
      error: function(results) {
        if(results.status == 404) {
          $(".xhrStatus").html('No more posts to show...');
        }
        else {
          $(".xhrStatus").html('Error retrieving posts...');
        }
      }

    });
  }
  return false;
});

0 个答案:

没有答案