I've a problem with my interval function. This is my function: 

```
let data = {
    action: "verify_status",
};

let interval = setInterval( function () {
    if ( new Date().getTime() - startTime > 600000 ) {
        alert( "Error: Timed out!" );
        clearInterval( interval );
    }

    jQuery.post( ajax_url, data, function () {
    } ).success( function () {
        clearInterval( interval );
        successFunction();
    } ).fail( function ( response ) {
        if ( response.status === 500 ) {
            clearInterval( interval );
        }
    } );
}, 5000 );

```

My problem is now the following: The interval starts an AJAX request, which now runs in parallel. This is fine as long as the request fails with `HTTP 400`. 

But if it runs successfully, my `successFunction()` is called. Unfortunately the interval continues running outside. As a result my `successFunction()` is called twice and sometimes three times, although I interrupt the execution with `clearInterval()`. Does anyone have an idea how I can do this better?