如何通过Ajax将数据发送到页面,然后立即查看该数据?

So I know how to write ajax code I just don’t know how to use it in my project as far as the way the data flows and how the pages are structured. So I am building a to do app. I did in plain PHP with 1 list and the ability to add tasks. Now I’m trying to have multiple lists. And of course update the content based on which ever list is clicked. Here’s my code so far:

function ajax_Request(list){ 
    let xhr = new XMLHttpRequest();
    xhr.open("GET", 'index.php?name=' + list);
    xhr.send();
    xhr.onreadystatechange = function() {
         if(xhr.readyState === 4 && xhr.status === 200) {
             window.location.href = 'http://localhost:8888/index.php?name=' + list;

         }
    }
}

The data is sent via GET but it gets erased when I redirect to the page so idk how to think about it. I encountered the similar problem with a previous Quiz App.