我有一个带有click事件的按钮,该按钮会将fetch
请求发送到api,大约需要30秒才能响应。我有另一个按钮与上一个按钮完全相反。用户同时单击两个按钮可能会导致意外结果。我想阻止所有提取请求,但有未解决的提取。 (或其他选项,如果需要的话)
例如:
$(".button1").on("click", function(){
fetch("api.com/do_something")
.then(...)
});
$(".button2").on("click", function(){
fetch("api.com/do_opposite_something")
.then(...)
});
//One should be blocked while other is pending
这怎么可能?