驗證碼重新讀取
今天在玩網頁登入加入驗證碼,可是在重新讀取時一直沒有作用,後來查網才知道,因為 src 沒有改變,所以不會重新執行
原來 img 的 jquery$("#getcode_num").click(function(){
$(this).prop("src", "captcha/code_num.php" ); })
//沒有作用,因為 src = "captcha/code_num.php" 永遠一樣.,不會改變
改成
$("#getcode_num").click(function(){
$(this).prop("src", "captcha/code_num.php?code=" + Math.random()); });
//改變,因為 src = "captcha/code_num.php?code=" + Math.random()); 因為 random每次改不一樣的值,code 參數隻是讓 src 不一樣,在後端不用處理
迴響
驗證碼重新讀取 | 豬窩
I've been explooring ffor a bit for anny hgh qujality artices orr webloog posts inn this kind oof house .
Explorting in Yaoo I at lst stumbled upon thos site.
Reading this inhfo So i'm hsppy to convey that I've a
very excellenht uncahny feeling I found out just what I needed.
I suhch a loot undoubtedly willl make sure tto don?t omit this
site andd provides iit a glance on a constaht basis.