Get Current User decimal digits and 1000s separator

Hello,
i am currently need to create a js function to do some calculation.
So i am creating an ajax call to a custom Entrypoint which will have to retrieve UserPrefs decimal digits and 1000s separator.
So which is the best way to do in php entrypoints? I’ve starting with:

global $current_user;
print_r($current_user);

but i am not able to find this info.

Many Thanks

@rainolf
Change call to

print_r($current_user,true);

Seems nothing happens.
I’ve tried instead:

require_once("modules/Currencies/Currency.php");
print_r(get_number_separators());

And seems to work, without including globals

Unfortunately too early to smile!
The Entrypoint is correct however the js function still get me undefined because of deferred ajax call .
The js function where the js file is added like an include in editviewdefs:

$(document).ready(function() {
    var test = getUserInfo();
    alert(test.tSeparator); //which should return "."
});

Then the getUserInfo():

function getUserInfo() {
    $.ajax({
        type: "POST",
        url: 'index.php?entryPoint=getUserInfo', // Custom EntryPoint
        //url: 'index.php?module=CDZ_Contracts_Mobile&action=getUserInfo', // Action in Custom Controller
        dataType: "json",
        success: function(data) {
            var yourDataStr = JSON.stringify(data) 
            var obj = JSON.parse(yourDataStr);
            // Run the code here that needs
            //    to access the data returned
            alert(obj.tSeparator);
            return obj;
        },
        error: function() {
            alert('Error occured');
        }
    });
}

The alert in getUserInfo works as expected while alert(test.tSeparator); will return undefined.
In console i can see:
jQuery.Deferred exception: test is undefined

Any help is appreciate.

And what is the main difference between make an ajax call to a custom action in controller or to a custom Entrypoints?

Which would be better?

Many Thanks

@rainolf

  1. Did you registry entryproint here: custom/Extension/application/Ext/EntryPointRegistry/ (documentation: https://docs.suitecrm.com/developer/entry-points/)
  2. Do you sure that you entryproint return format JSON?

Yes,
the entrypoint is registered and it works well and it returns valid json, this is my test code:

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once("modules/Currencies/Currency.php");
$result = get_number_separators();
$userDelimiters = array(
    'tSeparator' => $result[0],
    'dSeparator' => $result[1]
);
echo  json_encode($userDelimiters);
exit

As mentioned the

alert(obj.tSeparator);

inside getUserInfo function works as expected but if i call call the funciton from outside like here:
var test = getUserInfo();
and then i try to print the result like this:
alert(test.tSeparator);

It return Undefined probably because the value is returned before waiting async ajax to complete.
What do you think about?
Am i in a right way?
What needs to be changed?

Many Thanks

@rainolf

  1. ajax don’t return anythink (https://api.jquery.com/jquery.ajax/#jQuery-ajax-url-settings).
  2. If you declared object xhr it chould return XMLHttpRequest

Is there any SuiteCRM example for that?
It could be a good starting point.

There are some simple $.getJSON Ajax calls in
include/InlineEditing/inlineEditing.js

which call controller functions in
modules/Home/controller.php

which call helper functions in
InlineEditing/InlineEditing.php

ok thanks.
i will check and let you know.