PHP: Reloading the captcha image from javascript

主宰稳场 提交于 2019-12-04 17:42:50

You need to inject captcha.php into the page using ajax. There are several ways to do this:

  • javascript using XHR but this can be a pain. Here is an example.
  • jQuery provides a simple way to do this, for example:

    $('#someButton').click(function() { $('#someDiv').load('captcha.php'); });

  • prototype.js is a bit more verbose, but does the job. Example.

I would suggest using jQuery, there are great examples in the docs.

If your registration page returns on a validation error, you do not need to use javascript for the captcha to get reloaded, that should happen automatically.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!