mardi 9 juin 2020

On click get ajax request 4 times

Get issues when i click one time i got 4 request on console. like this. enter image description here

here is my code

var opener = listTreck.find('.row-holder');

opener.on('click.b touchstart.b', function() {

  refreshPosition();

  var self = jQuery(this);
  if (!self.parent().hasClass('active')) {
    openerParent.removeClass(activeClass);
    self.parent().addClass('active');
  } else if (self.parent().hasClass('active')) {
    openerParent.removeClass(activeClass);
  }

  if (!row.hasClass('details-open')) {
    colSlide.stop().animate({
      marginLeft: -slideWidth
    }, animeSpeed);
    trackDetails.stop().animate({
      marginLeft: -slideWidth
    }, animeSpeed, function() {
      row.addClass('details-open');
      resetStyle();
      colHidden.css({
        display: 'block',
        position: 'absolute',
        left: '0',
        marginLeft: -slideWidth
      });
    });
  }

  if (self.attr('data-src')) {
    var url = self.data('src');
    //var data = { _token: _globalObj._token };
    var data = {};

    if (isRoute('/favorites')) {
      data.f = true;
    }

    jQuery.ajax({
      url: url,
      type: 'GET',
      data: data,
      dataType: 'html',
      success: function(data) {
        ajaxHolder.hide().text('');
        var html = jQuery('<div>').html(data);
        html.appendTo(ajaxHolder);
        ajaxHolder.fadeIn('normal', function() {
          scrollTrackInfo();
        });

      },
      error: function() {
        if (window.lonsole) {
          console.log('ajax Error');
        }
      }
    });
  }
});

when i click .. then i got issue on console request.why my ajax call 4 times. i got data properly on this code but only issue is... get many request.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hfMqFo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire