You need to check your browser's developer tools for errors, and inspect the network request to see what data is sent to the server, and what response comes back.
In this case, I suspect you're getting an
array of objects back, where your code is expecting a single object:
success: function(data) {
console.debug(data);
To fix that, you need to change your action so that it only returns a single record:
[HttpGet]
public IActionResult GetDepartmentAndManager(string nazwaValue)
{
var danePracownika = _uzytkownicyContext.Uzytkownicy.FirstOrDefault(x => x.Nazwa == nazwaValue);
if (danePracownika is null) return NotFound();
return Json(new
{
UserDepartament = danePracownika.Departament,
UserManager = danePracownika.Manager
});
}