开发者

jquery load method

开发者 https://www.devze.com 2022-12-28 01:54 出处:网络
I am using mscaptcha image and trying to only reload the captcha image on button click. Seems like the captcha image is being loaded twice sometimes.

I am using mscaptcha image and trying to only reload the captcha image on button click. Seems like the captcha image is being loaded twice sometimes.

 <script ty开发者_Python百科pe="text/javascript">
        $(document).ready(function() {
            $('#btnSubmit').click(function() {
                $('#dvCaptcha').load('default.aspx #dvCaptcha');                
            });
        });
  </script>

<div id="btnDiv">
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>

<div id="dvCaptcha">
    <cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none"  CaptchaLength="5" CaptchaHeight="60" CaptchaWidth="200" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"  />
</div>

Any ideas?


I'm not all too familiar with asp, but from the top of my head I can think that maybe if you add a "return false" will keep the browser from doing anything unexpected.

Try this:

$('#btnSubmit').click(function() {
    $('#dvCaptcha').load('default.aspx #dvCaptcha');
    return false;     
});

Hope this helps!


If the problem is related to clicking the submit button more than once, then disable it until the response is received:

 <script type="text/javascript">
        $(document).ready(function() {
            $('#btnSubmit').click(function() {
                $(this).attr("disabled", "disabled");
                $('#dvCaptcha').load('default.aspx #dvCaptcha', function() {
                    $('#btnSubmit').removeAttr("disabled");
                });   
                return false;             
            });
        });
  </script>
0

精彩评论

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