dqftyn1717 2014-03-29 09:50
浏览 64
已采纳

OpenCart - 如何在点击时重新加载验证码图像?

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.

  • 写回答

1条回答 默认 最新

  • doru52911 2014-03-29 10:04
    关注
    <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?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了