Skip to content

Instantly share code, notes, and snippets.

@MrWhiteD
Last active July 25, 2025 05:59
Show Gist options
  • Select an option

  • Save MrWhiteD/c662009e95bd246c11a53a23ec8abcd2 to your computer and use it in GitHub Desktop.

Select an option

Save MrWhiteD/c662009e95bd246c11a53a23ec8abcd2 to your computer and use it in GitHub Desktop.
[Обновление капчи] #captcha #капча
/* Обновление капчи */
$('#captcha_img').on('click', function () {
BX.ajax.getCaptcha(function(result) {
$('#captcha_sid').val(result["captcha_sid"]);
$('#captcha_word').val('');
$('#captcha_img').attr('src', '/bitrix/tools/captcha.php?captcha_code='+result["captcha_sid"]);
});
});
-----------------------------------------------------------------------
с использованием BX.proxy
BX.ready(function(){
$('.captcha__reset').on('click', function () {
BX.ajax.getCaptcha(BX.proxy(function(result) {
$(this).closest('.captcha').find('[name="captcha_sid"]').val(result["captcha_sid"]);
$(this).closest('.captcha').find('[name="captcha_word"]').val('');
$(this).closest('.captcha').find('.captcha__image').attr('src', '/bitrix/tools/captcha.php?captcha_code='+result["captcha_sid"]);
}, this));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment