Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Load captcha.php to img selector

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31033
    wattsup
    Member

    what I would like to know is it possible to use jquery to reload the image that captcha.php creates without a page refresh? Here is what I have tried but seems not to work to well.

    Working code with page refresh/reload:







    Not readable? Change text.

    Here is what I like to change:


    Not readable? Change text.

    $('#change-image').click(function(){
    $("#secure-image").load("", function(){
    return false;
    });
    });
    #69573
    wattsup
    Member

    after searching google I created this and it works. So just in case someone needs it.


    $("#change-image").click(function(){
    reload_image();
    });

    function reload_image(){
    var img = new Image();

    $(img).load(function () {
    $('#captcha').remove();
    $('#secure-image').append(this);
    }).attr('src', 'security/captcha.php?'+Math.random()).attr('id','captcha');
    };
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.