【问题标题】:OpenCart - How to reload captcha image on click?OpenCart - 如何在点击时重新加载验证码图像?
【发布时间】:2014-08-13 17:12:00
【问题描述】:

有很多关于如何在点击时重新加载验证码图像的示例,它们都有一个'captcha.php'作为图像源,例如

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

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

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

我的表单中OpenCart中的图片来源是

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

如果我这样做:

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

第一张图片加载,但是当我点击图片时,新图片没有加载。看起来我没有指定正确的 URL。我需要在 OpenCart 的脚本中设置什么路径?谢谢。

【问题讨论】:

    标签: php image opencart captcha reload


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

    这行得通吗?

    【讨论】:

    • 可以!非常感谢你,伙计!非常感谢。
    猜你喜欢
    • 2016-01-11
    • 2011-09-04
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 2012-12-17
    • 2012-01-23
    • 1970-01-01
    相关资源
    最近更新 更多