How will my javascript function executed after the previous ajax call complete ?

  • 5 years-11 months

    How will my javascript function executed after the previous ajax call complete ?

    • Category : wordpress
    • Viewed : 38 times
    • Posted On :
    • Posted by : Vikas

    You can specify a function identifier in a custom property in your .ajax() call and use the value of that in your ajaxComplete() callback.

    For example, get any ajax property while making your .ajax() call:
    function foo() {
        $.ajax({
            url: 'my-page.php',
        });
    }
    
    And then, use any of ajax property to ajaxComplete() like this:
    $('#my-unique-id').ajaxComplete(function(e, xhr, settings) { // run after all ajax complete 
        if (settings.url == 'my-page.php') { // write condition according to your requirement
            // execute you code
        } else {
            // execute you code
        }
    });
     

Report this or Ask your own question

Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.