var Qs_Form_Element_Captcha = { message: new Qs_Message({ 'eng': { }, 'uk': { } }), refresh: function (a) { $(a).addClass('loading_captcha'); $.ajax({ url: a.href, type: 'GET', data: {action: 'refresh'}, dataType: 'json', error: function(request, status, error) { alert(status + ' ' + error); }, complete: function() { $(a).removeClass('loading_captcha'); }, success: function(response) { if (response.isValid) { a.href = a.href.replace(response.oldId, response.newId); var img = $('img:first', a); if (img.size()) { img = img.get(0); img.src = img.src.replace(response.oldId, response.newId); } var name = $('input:hidden[value="' + response.oldId + '"]').val(response.newId).attr('name'); name = name.replace(/\[id\]/, '[input]'); $('input[name="' + name + '"]:text').val('').focus(); } } }); return false; } }