D
D
Dc8882016-03-01 14:51:42
JavaScript
Dc888, 2016-03-01 14:51:42

Ajax request, how to reset old request?

Good day, the essence of the problem: there are categories that are loaded by ajax in these categories there is data that is loaded by lazy subloading (scrolling down), the problem is that if you do not load the data to the end from one category - this data is loaded in another category ... Those it is necessary that when changing the category, everything is reset. I don't understand how to do it, can someone tell me?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zhainar, 2016-03-01
@zhainar

var request = $.ajax({....});
request.abort();

Try like this:
var toloadRequest;
jQuery('document').ready(function(){	
    // клик для загрузки категории
      jQuery('.click').on('click', function(){	
      oneload;
      if( typeof  toloadRequest !== 'undefined' ) { toloadRequest.abort(); }
      toload;
    });	
    
  // загрузка категории
    function oneload() {
        $.ajax({...});
    }
  // ленива загрузка из категории
  function toload() {
    toloadRequest = $.ajax({...});			   
    }
    });

D
Dc888, 2016-03-02
@Dc888

Here is an example code, maybe it's easier to explain what I want to do =))

jQuery('document').ready(function(){	
    // клик для загрузки категории
      jQuery('.click').on('click', function(){	
      oneload;
        	toload;
    });	
    
  // загрузка категории
    function oneload() {
        $.ajax({...});
    }
  // ленива загрузка из категории
  function toload() {
    $.ajax({...});			   
    }
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question