Skip to content

Instantly share code, notes, and snippets.

@ASDAFF
Created September 5, 2019 19:19
Show Gist options
  • Save ASDAFF/5e1700e6ea726ce2671a6e007ca86770 to your computer and use it in GitHub Desktop.
Save ASDAFF/5e1700e6ea726ce2671a6e007ca86770 to your computer and use it in GitHub Desktop.
Регистрация пользователя Ajax Битрикс
<?
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
global $USER;
$arResult = $USER->Register($_REQUEST['mail'], $_REQUEST['name'], $_REQUEST['last_name'], $_REQUEST['pass'], $_REQUEST['pass'], $_REQUEST['mail']);
exit(json_encode($arResult));
//регистрация нового пользователя
$(document).on("click", '#register', function(e) {
e.preventDefault();
$.ajax({
url: '/local/ajax/register.php',
data: {
name: $('#register_form input[name="name"]').val(),
last_name: $('#register_form input[name="last_name"]').val(),
phone: $('#register_form input[name="phone"]').val(),
pass: $('#register_form input[name="passw"]').val(),
mail: $('#register_form input[name="mail"]').val(),
},
dataType: 'json',
success: function(result){
if(result.TYPE == 'ERROR'){
$('#register_result').html(result.MESSAGE).css({"color": "red"});
}else{
$('#register_result').html(result.MESSAGE).css({"color": "green"});
setTimeout(function(){
location.reload();
}, 1000);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment