i have content listed in a div and i have a dropdown with various options to order and filter that content. I'm using ajax to filter/order that content and is working but i use other php page with the content i want on the div that has the content, like this
 function order(str){
    $.post("order_products.php",
    {
        q: str,
    },
    function(data, status){
      document.getElementById("txtHint").innerHTML = data;
    });
  }
What i wanted was to instead of putting the code (data) to change in another page just for that, i could put that code inside a class php function that i have.
<?php
class products{
    function list(){
        blablabla
    }
That way i would "save space" and organize everything, considering that i have many other things to order/filter but i don't know to to make the ajax request to that function, or if it's possible without having a page in between and then get the response from the function and put it on the div.