Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Loader works only on the first ajax call

I want the loader to stay until the complete execution is complete and statement $("#xyzDiv").html(data) has been executed. Currently the loader gets hidden after the first ajax call. Even if i add "beforeSend: function () { $("#loader").show(); }" to GetDataList(), the loader is not staying.

$.ajax
({
    type: "POST",
    url: ajaxUrl,
    data: dataObj,
    beforeSend: function () { $("#loader").show(); },
    success: function (data)
    {
        if (data.result)
        {
            GetDataList();
            toastr.success(data.strMsg);
        }
        else
        {
            toastr.error(data.strMsg);
        }
    },
    error: function (jqXHR, textStatus)
    {
         var msg = HandleAjaxErrorMessage(jqXHR, textStatus);
        console.log(msg);
        toastr.error('An error occurred. Please try again');
    },
    complete: function () { $("#loader").hide(); }
});

function GetDataList()
{
    $.ajax
    ({
        type: "Get",
        url: ajaxUrl,
        data: dataObj,
        success: function (data)
        {
            $("#xyzDiv").html(data);
        },
        error: function (jqXHR, textStatus) 
        {
            var msg = HandleAjaxErrorMessage(jqXHR, textStatus);
            console.log(msg);
            toastr.error('An error occurred. Please try again');
        }
    });
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!