刷新简单验证码 [英] Refresh Simple Captcha
本文介绍了刷新简单验证码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的JSP中使用简单验证码。一切都好。我想在验证码旁边提供刷新按钮以允许用户更改验证码。 Captcha仅在刷新完整页面时进行更改,但我不想重新加载整个页面。
I am using simple captcha in my JSP. Everything is OK. I want to provide a refresh button alongside of captcha to allow user to change the captcha. Captcha changes only on refreshing the complete page but I don't want to reload whole page for it.
我需要关于如何使用AJAX或JQuery来重新加载验证码而不是整个页面的建议。
I need your suggestions on how I can implement this like using AJAX or JQuery to reload only the captcha, not whole page.
推荐答案
<script type="text/javascript">
function reloadCaptcha(){
var d = new Date();
$("#captcha_image").attr("src", "/captcha_generator.jsp?"+d.getTime());
}
</script>
...
<img id="captcha_image" src="/captcha_generator.jsp" alt="captcha image" width="200" height="50"/>
<img src="reload.jpg" onclick="reloadCaptcha()" alt="reload"width="40" height="40"/>
这篇关于刷新简单验证码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文