Created
September 5, 2019 19:20
-
-
Save ASDAFF/573e8193da79366268099cdf8d2fb149 to your computer and use it in GitHub Desktop.
Авторизация пользователя Ajax Битрикс
This file contains 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
<? | |
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
global $USER; | |
if (!is_object($USER)) $USER = new CUser; | |
$arAuthResult = $USER->Login($_REQUEST['login'], $_REQUEST['pass'], "Y"); | |
$APPLICATION->arAuthResult = $arAuthResult; | |
exit(json_encode($arAuthResult)); |
This file contains 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).on("click", '#auth_submit', function(e) { | |
e.preventDefault(); | |
$.ajax({ | |
url: '/local/ajax/auth.php', | |
data: { | |
login: $('#auth_form input[name="login"]').val(), | |
pass: $('#auth_form input[name="pass"]').val(), | |
}, | |
dataType: 'json', | |
success: function(result){ | |
if(result.TYPE == 'ERROR'){ | |
$('#auth_result').html(result.MESSAGE); | |
}else{ | |
location.reload(); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment