Display readings on Webpage from ESP32 to Webserver

Basically, I am sending an array from ESP32 to my webserver created on the said ESP32 and then displaying it on my webpage. For example, I am sending my ESP32 IP address and trying to display it.

What I did on my esp32 is

data_string = String(a, 3)
                + "," + String(b, 3)
                + "," + String(c,  3)
                + "," + String(ipaddress);

and sending it as


server.on("/readings", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(200, "text/plain", data_string.c_str());

I am receiving the array on my reading page but I would like to show them on my page.
for which I did.

<h1>IP Address:<span id="ipaddressvalue">0</span></h1><br>

<script>
var ip = String("http://192.168.18.84");

  setInterval(function() {
  getipaddress();
}, 2000); 

    function getipaddress() {
    var request = String(localinstance ? ip + "/ipaddress" : "/ipaddress");
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
      if (this.readyState == 4 && this.status == 200) {
        document.getElementById("ipaddressvalue").innerHTML =
        String(this.responseText);
      }
  };
  xhttp.open("GET", String(request), true);
  xhttp.send();
}

</script>

but I can't get it to work. Any ideas?