0

Simple button, How do I disable the button immediately? my api call is not async, but I dont want user submitting multiple requests?

Example? Search

    function GetClient() {
    $("#btnSubmitCode").prop("disabled",true);

    //Ajax call here

//takes a few seconds to go and get info from api
}

1 Answer 1

1

You could use ajax call setup for disable the button.

$.post(your_api_url, { data,
    beforeSend: function() {
        $("#btnSubmitCode").prop("disabled",true);
    },
    error: function() {
        $("#btnSubmitCode").prop("disabled",false);
    },
    success: function(data) {
        $("#btnSubmitCode").prop("disabled",false);    
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.