Proper way to handle admin-ajax calls

The PHP part of your code looks more or less OK. (There are some security concerns and you shouldn’t echo an array of objects, but you’ll get it when you see it).

But your code doesn’t work because of an error in your JS.

You should send “action” as data and not as a setting… so it should look like this:

$.ajax({
    url: my_ajax_object.ajax_url,
    type: 'GET',
    dataType: 'json', // added data type
    data: {
        action: 'getListings',
    },
    success: function(res) {
        console.log(res);
    }
});