In my app (but this is valid also for web app), I have a problem: if user clicks twice (or more), twice requests (or more) are sent to the API server. Here a snippet to avoid this behavior with useless requests.

var pending = false;

function Foo(param)
    // test to see if something else set the state to pending.
    // if so... return, we don't want this to happen.

    pending = true; // raise the flag!

    /* ... later ... */
    // in the success method of your AJAX call add:
    pending = false;