Home  >  Article  >  php教程  >  Thinkphp 边学边用-验证码无意间犯的错

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

WBOY
WBOYOriginal
2016-06-21 08:47:221143browse

先看代码:

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();

 

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



Statement:
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