Home > php教程 > php手册 > body text

Thinkphp 边学边用-验证码无意间犯的错

WBOY
Release: 2016-06-21 08:47:22
Original
1145 people have browsed it

先看代码:

1 $(".verify_img").click(function(){

2         var timenow = new Date().getTime();

3         var url ="{:U('index/loginverify')}&t="+timenow;

4         alert(url);

5         $(this).attr("src",url)

6     });

以上代码导致验证码点击切换导致验证码图片无法显示。

 

再看下面代码:

 

 $(".reloadverify").click(function(){

     var timenow = new Date().getTime();

        var url ="{:U('index/loginVerify')}?t="+timenow;

       $("#image_d").attr("src",url) 

    });

以上代码的区域是?和&的区别。对比之后就可以看出问题就处在哪儿。还有在问号后面直接跟上一个随机数也是有效的。var url ="{:U('index/loginVerify')}?"+Math.random();

 

写道这里问题就已经很清楚了。



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template