Question

There's a lot of examples about how to reload captcha image on clicking, they all have a 'captcha.php' as the image source, e.g.

<img id="captcha" src="captcha.php">

<a id='reload'>Refresh now</a>

$('#reload').click(function(){
    $('#captcha').attr('src','captcha.php')
})

The image source in OpenCart in my form is

<img id="captcha_img" src="index.php?route=information/contact/securimage" alt="CAPTCHA Image" />

If I do this:

<script>
$(function() {
    $('#captcha_img').click(function(){ 
        $('img').attr('src', '<?php echo "index.php?route=information/contact/securimage" ?>?' + (new Date).getTime());
    });
});
</script>

The first image loads, but when I click on the image, the new image doesn't load. Looks like I'm not specifying the correct URL. What path do I need to set in the script in OpenCart? Thank you.

Was it helpful?

Solution

<script>
$(function() {
    $('#captcha_img').click(function(){ 
        $(this).attr('src', '<?php echo "index.php?route=information/contact/securimage" ?>&time=' + (new Date).getTime());
    });
});
</script>

Is that works?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top