.DataTable().ajax.url(testURL).load(); event on complete

.DataTable().ajax.url(testURL).load(); event on complete

ArudianArudian Posts: 11Questions: 5Answers: 1

HI,

I am using .DataTable().ajax.url(testURL).load(); to reload my page (based on some filters)

I was wandering if its possible to run some javascript function after this specific ajax request is completed.

I can't use $(document).ajaxComplete because i have more than 1 ajax request on page happening and i don't want those functions to be run on each ajax complete.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi Arudian,

    The xhr may help, though I'm not sure how you could differentiate between the various other Ajax requests - maybe something like setting a flag or interrogating the data if it's going to be of a certain format for only that specific request.

    Hope that helps,

    Cheers,

    Colin

  • ArudianArudian Posts: 11Questions: 5Answers: 1

    Thank you Colin, in this case i decided to go with $(document).ajaxStop(function () insted. It is not perfect as it dosen't target the specific ajax call, but is enough to serve my purpose.

    BR,

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    edited March 2018 Answer ✓

    ajax.url().load() has a callback option that would be what you want in this case.

    Allan

  • ArudianArudian Posts: 11Questions: 5Answers: 1

    Can't belive i have missed this.... Thank you Alan, exactly what i was looking for.

    BR.

This discussion has been closed.