XML Response Text and JSON

I have a webpage hosted on the Arduino Uno with the Ethernet Card. On the Ethernet's SD Card, I have a JSON file named "data.txt"

I want to be able to store all the JSON info from data.txt onto a variable (called mydata) using Javascript from my webpage.

I feel like I'm pretty close...Hopefully my code can explain better.

Here is the function that I'm calling from my webpage.

function loadJson() {
 var request = new XMLHttpRequest();
request.open("GET", "data.txt", false);
request.send(null);
request.onreadystatechange = function() {
  if ( request.readyState === 4 && request.status === 200 ) {
    var mydata = JSON.parse(request.responseText);
  }
}
}

I'm pretty confident that is the correct way to request the file, but my main problem is - I do not know how to handle this request from the Arduino side! I know it has to look something like this, but I'm at a loss at how it should respond:

if (StrContains(HTTP_req, "GET /data.txt")) {
                       
//DO SOMETHING HERE TO RESPOND TO JAVASCRIPT REQUEST.  ?????
                  
                        
                    }

Anyone out there provide me with some direction?

//DO SOMETHING HERE TO RESPOND TO JAVASCRIPT REQUEST.  ?????

Maybe more detailed explanation of what you to want happen here. You want to send the data.txt back to the client?

zoomkat:

//DO SOMETHING HERE TO RESPOND TO JAVASCRIPT REQUEST.  ?????

Maybe more detailed explanation of what you to want happen here. You want to send the data.txt back to the client?

I'm search for the same thing, I want to send json data back to client