Ajax appears not to work when not logged into manager

I am using Ajax to retrieve data from a custom database and it works fine if I am still logged in the backend. If I log out then the data is not retrieved and nothing is presented after the select is chosen. I am using select2 with migxloopcollection to select the correct data.

I have followed the information within Modx documentation and Ajax is calling a url that is a resource without a template.

Is this anything to do with context? What do I have to do to enable the the website to work when I am not logged as a manager? It seems bizarre that it only works that way and will prevent people who may log into my site from getting the data. The site can be viewed but just does not provide any data when using a select with Ajax.

Any help would be appreciated

Is this “AJAX” resource published?
Is it maybe assigned to a resource group that restricts access to it?
If not, can you share more information what exactly you are executing in this resource?

Also, when you open the developer tools in the browser and go to the “Network” tab and then trigger the AJAX call, is there something in the response that indicates why the AJAX-call is unsuccessful? What’s the response code?

Thanks halftrainedharry. I shall look into it. By response code what am I looking for?

I have not set up any resource groups either.

The normal HTTP response status code. Like for example “404 Not found” or “401 Unauthorized”.

I did notice a 404. But why does it only work when I am logged into the manager?

Is the resource (that serves as an AJAX endpoint) published?

Thanks once again halftrainedharry. It appears to be as simple as the end resource not being published. I hoped it would be something simple but I still missed it. Thanks again.