Ajax is not working in a loop

Your code has

 var getid = $('#my-categorychecklist input:checked').last().val();

see the .last(), that’s why you’re only getting the last item
Also, why do you have the same thing in getid and matchid?

You need to store the selected categories in an array and loop through them,
try something like:

var selected_cats = $('#my-categorychecklist input:checked').map(function() {
    return this.value
})

(without the .get())
then loop through them with

    selected_cats.forEach(function(element) {
        console.log(element)
      //make sure element has what you're expecting then do you something on element
}

Try doing console.log() on each variable and see in your console, if the the variables have the result you’re expecting. Make sure that selected_cats has an array of the selected categories