Purpose : to refresh the captcha image.
routes.php
Route::get('/get_captcha/{config?}', function (\Mews\Captcha\Captcha $captcha, $config = 'default') {
return $captcha->src($config);
});
captcha image (mypage.blade.php):
<img src="{{ Captcha::img() }}" alt="captcha" class="captcha-img" data-refresh-config="default">
js file:
$(document).ready(function(){
$('img.captcha-img').on('click', function () {
var captcha = $(this);
var config = captcha.data('refresh-config');
//console.log(config);
$.ajax({
method: 'GET',
url: '/get_captcha/' + config,
}).done(function (response) {
captcha.prop('src', response);
});
});
});
Issue : js ajax error on my console : http://localhost/get_captcha/default 404
error.
reference : https://github.com/mewebstudio/captcha/issues/54#issuecomment-141483501
Additional information : I'm using captcha for Laravel 4, and i wasn't able to find a method called src
, in the line above $captcha->src($config)
Thank you in advance.