Jquery load method

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

 <script type="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?

+2


a source to share


2 answers


I'm not very familiar with asp, but from the top of my head I can think that maybe if you add "return false" it will make the browser do something unexpected.

Try the following:



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

      

Hope this helps!

0


a source


If the issue is related to clicking the submit button more than once, disable it before receiving a response:



 <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


a source







All Articles