Esp8226 external switch update to web server with

I think you have some misunderstanding about AJAX.

This is what I would do. Use php to update a database.

I don't have time to write the the whole code for it but you might be able to find a project like this online. I'll give you the basic steps for you to get an idea.

  1. Setup a web server (Use something like XAMPP).
  2. Create a MySQL database.
  3. Create a .php file that updates the MySQL database by receiving data via a GET request.
  4. Use your ESP8266 to send the GET request containing your data.

So when your ESP8266 sends data via a GET request, your .php file takes them and puts them in the database. Then you can show the data in the database on a webpage. You can also create an API and use AJAX to show it on a web page and update the data without refreshing the page.

If you have no idea about what I'm talking about, search YouTube with "Send Data From ESP8266 to MySQL Database" you will find so many projects and tutorials.

Hope this helps. Good Luck!