开发者

while requesting / after click block the button or something?

开发者 https://www.devze.com 2023-01-21 05:39 出处:网络
I have this upload then you can crop your image, but if you press twice开发者_如何学编程 quickly then it uploads 2 and it all gets crazy. How can i block the button RIGHT after it starts sending reque

I have this upload then you can crop your image, but if you press twice开发者_如何学编程 quickly then it uploads 2 and it all gets crazy. How can i block the button RIGHT after it starts sending request, and where should i place it?

(in jquery ajax)


You could try this:

<button id="foo">Click</button>
<script type="text/javascript">
    $(function() {
        $('#foo').click(function() {
            $(this).attr('disabled', true);
        });
    });
</script>

The important part of course is $(this).attr('disabled', true); You can then enable the button again by setting the attribute to false.

0

精彩评论

暂无评论...
验证码 换一张
取 消