jQuery - AutoComplete

The jQuery ajaxComplete() method specifies a function to be run when an AJAX request completes....regardless...if the request was successful.

The example below is designed NOT to work (bad file name) but the complete method will be executed regardless. autoComplete() is invoked only if there is an ajax call.


$(document).ready(function ()
{
    const ShowComplete = () =>
    {
        $("#ajax-content").html("AJAX request **completed** even though it was not successful.");
    };

    $("#ajax-content").load("ajax-sample-foo.txt");

    $(document).ajaxComplete(function ()
    {
        ShowComplete();
    });
});