The input box defocus event and button click event trigger bug at the same time

problem description: when the input box loses focus, it will request the API to obtain data. When the button is clicked, it will determine whether the data can proceed to the next step. When I have finished typing, I will click on the next step, which will trigger the input box blur event and button click event at the same time. At this time, the API may not return the result, resulting in going directly to the next step . How to solve this problem?

Jun.22,2022

make the button unclickable before the data comes back, and then let the button click when the data comes back. Or click the button not to execute anything before the data comes back, and directly return


lose focus and go to the interface to request data is a bit unreasonable. You can consider making a judgment when you click on the next step. If not, you can make relevant prompts instead of button clicks.


provides an idea. For reference
, set a flag variable record whether the result returned by the request has been obtained. It is isGetResult, and the initial value is false. If the request result of the previous step has been obtained, isGetResult = true. When performing the next operation, check whether the isGetResult is true. If it is true, if the next step is false, send the request of the previous step
first. When the user directly clicks the next step after entering the content, isGetResult is false, which will first send a request to judge the data, and then proceed to the next step after obtaining the result of the request.
Note: every time users focus, remember to set isGetResult to the initial value, that is, false

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5bcb5-44ba1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5bcb5-44ba1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?