search

Home  >  Q&A  >  body text

javascript - When clicking a button to add content, if the network is stuck, clicking multiple times will add multiple content.

When clicking the button to add content, if the network is stuck, clicking the button multiple times will send multiple requests and add multiple content. How should the front end handle it.

为情所困为情所困2809 days ago567

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-05-19 10:12:22

    1. Set the button to disabled when clicking send

    2. Send a request

    3. After requesting the callback (regardless of success or failure), set the button to be available

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:12:22

    Disable the button after clicking it, wait for the network to respond, and then undisable it

    reply
    0
  • Cancelreply