Home  >  Q&A  >  body text

tp5 uses ajax to realize verification code refresh and click no response

The following is part of the html verification code

<div class="row cl">
        <div class="formControls col-xs-8 col-xs-offset-3">
         <input class="input-text size-L" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;">
            <img id="verify_img" src="{:captcha_src()}" onclick="this.src=this.src"> <a id="kanbuq" href="javascript:refreshVerify;">看不清,换一张</a>
</div>
</div>

javacript

<!-- <script>
    // 用下面方法点击刷新无反应
    function refreshVerify() {
        var ts = Date.parse(new Date())/1000;
        $('#verify_img').attr("src", "/captcha?id="+ts);
    }
</script> -->
<script>
    //在家里用这个方法可以实现点击文字刷新,在单位电脑上依然无任何反应
    function refreshVerify() {
        var ts = Date.parse(new Date())/1000;
        var img = document.getElementById('verify_img');
        img.src = "{:captcha_src()}";
    }
</script>

May I ask why this is! ! ! ! Solve

杨云雷杨云雷2164 days ago1301

reply all(4)I'll reply

  • 尓於我適

    尓於我適2018-09-04 17:39:42

    Brother, I have the same problem, can you help me answer it


    reply
    0
  • 杨云雷

    杨云雷2018-08-18 09:54:24

    It has been solved, no need to reply again

    reply
    0
  • You bad bad

    You bad bad2018-08-15 09:56:09

    I don’t quite understand, but how do you trigger your js?

    reply
    0
  • 杨云雷

    Click if you can’t see clearly and change to another one to trigger data-href="javascript:refreshVerify; This is from my teacher Zhu’s tutorial. I am also looking for ajax courses.

    杨云雷 · 2018-08-15 09:59:39
  • Cancelreply