How to Read .txt file in html table any one know?

i Am New in This Community. I have A Arduino Mega And Ethernet Shield,Matrix Keypad. I used it for store data in Sd card and Display In Web Server On Arduino Mega. I want To Read Data From Sd Card With Html Code. I also Read Data With Ifram Tag in Html Code. But I Want Do Display Data In Table tag. I Don't know Arduino Read .php or Ajax j Qery. I just Want My Data In A Table Tag is This Posible? Plese help Me.

Start a web server on the Arduino that serves both the HTML page and the txt data. In your HTML page, add a JavaScript script that makes an XMLHttpRequest that gets the txt data from the server, then parses it (using a simple CSV parser, or just using the string split method), and finally populates the table using the DOM interface.

Pieter

Is Arduino web server work with ajax j query?

What does jQuery have to do with this? The Arduino web server is just a simple HTTP server. Just use an XMLHttpRequest. If you use HTTP, you can GET data from the Arduino HTTP server.

I am New. This is my aruino Code:-

#include <Wire.h>
#include “RTClib.h”
RTC_DS1307 rtc;
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <FastIO.h>
#include <I2CIO.h>

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
byte gateway = { 192, 168, 1, 1 }; // internet access via router

EthernetClient client;
//////////////////////

EthernetServer server(80);

const int chipSelect = 53;

int led_out1=8;

//cs or the save select pin from the sd shield is connected to 10.
int a = 0;

File dataFile;

void setup(void){
Serial.begin(9600);
Serial.begin(9600);
if (! rtc.begin()) {
Serial.println(“Couldn’t find RTC”);
while (1);
}
Wire.begin();
if (! rtc.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(DATE), F(TIME)));
// This line sets the RTC with an explicit date & time, for example to set
//January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2019, 10, 25, 06, 46, 30));
}

Ethernet.begin(mac, ip);
//Ethernet.begin(mac);
server.begin();
Serial.begin(9600);

Serial.println(Ethernet.localIP());

Serial.println(“Initializing SD card…”);
if (!SD.begin(53)) {
Serial.println(“ERROR - SD card initialization failed!”);
return;
}
Serial.println(“SUCCESS - SD card initialized.”);
if (!SD.exists(“datalog.txt”)) {
Serial.println(“ERROR - Can’t find datalog.txt file!”);
}
Serial.println(“SUCCESS - Found datalog.txt file.”);
}

void loop(){
{

EthernetClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == ‘\n’ && currentLineIsBlank) {
client.println(“HTTP/1.1 200 OK”);//background-color: #DFEBED;
client.println(“Content-Type: text”);
client.println(“background-color: #DFEBED”);
client.println(“Connection: close”);
client.println();

dataFile = SD.open(“datalog.txt”);
if (dataFile) {
while (dataFile.available()) {
client.write(dataFile.read());

}
dataFile.close();
}
break;

}
if (c == ‘\n’) {
currentLineIsBlank = true;
}
else if (c != ‘\r’) {
currentLineIsBlank = false;
}
}
}

delay(1);
client.stop();
}
}
return;
}

This is where you tell the browser that what you are sending is plain text:

           client.println("Content-Type: text");

If you want to send an HTML table you should probably change that and start by sending some HTML headers.

This is where you send the plain text to the browser. If you want to send HTML, this is where you would add the HTML tags around your text to tell the browser how to display the table.

          dataFile = SD.open("datalog.txt");       
          if (dataFile) {
            while (dataFile.available()) {
              client.write(dataFile.read());
            }
           dataFile.close();

For example you should read the text file one line at a time so you can put and around each line and break it into fields so you can put and around each field.