Created
May 16, 2016 16:58
-
-
Save flayder/e3d6d3ae8b5322dbb141c05c47116d8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$("#add-obj").submit(function(){ | |
var fObj = $(this); | |
var formData = $(this).serialize(); | |
$.ajax({ | |
url: fObj.attr('action'), | |
type: 'GET', | |
data: formData, | |
processData: false, | |
contentType: false, | |
dataType: 'json', | |
success: function(data) { | |
if (!$.isEmptyObject(data['errors'])) { | |
var strErr = ''; | |
$.each(data['errors'], function(index, val) { | |
strErr += val + '<br />' | |
}); | |
fObj.children('.errors').html(strErr + '<br />'); | |
if (data['captcha']) { | |
$("#captcha_sid").val(data['captcha']); | |
$("#captcha_img").attr('src', '/bitrix/tools/captcha.php?captcha_sid=' + data['captcha']); | |
} | |
} else { | |
$(this).html('<div class="success">Ваше сообщение отправлено</div>'); | |
$('#form-add .title').hide(); | |
} | |
} | |
}); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment