$(function () {
	console.log('profile.js');
	var cur_url     = window.location.pathname;
    var arr_url     = cur_url.split('/');
	var role_page	= arr_url[2];
	
	$(document).on("click", ".btnSave", function (e) {
		console.log('[.btnSave] Clicked!');
		
        var pass		= $("#password").val();
		var pass_again	= $("#password-again").val();
		
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url: APP_URL + '/' + role_page + '/profile/update',
            type: "PUT",
            data: {				
                'pass'    		: pass,
                'pass_again'	: pass_again,                
            },
            // contentType: false,
			// processData: false,
            success:function(data){
                console.log('[.btnSave] data: ', data);               
                if(data.status == "success"){
                    SuccessPopup('<strong>Success</strong><br>Data has been saved.');
                } else{					
					AlertPopup("<strong>ERROR</strong><br>"+ data.msg);
                }
            },

        });
	});
});