Arduino ethernet webserver using javascript? - Solved

Hello, I'm just trying to figure out if arduino webserver can support javascript? I'm searching online and seeing a lot of people asking for help but I'm al ittle confused if it can support javascript? I'm asking the community if it can support it. I wanted to add some real time updates on what I'm monitoring for temerature and hudmidity without having to refresh the page. I just wanted to update the viewing of what I'm monitoring.

Joseph

Sure, JavaScript runs on the client.

You can try to add something like this to the HTML page you serve to test it.

<script>
  alert("Hi.");
</script>

yes you can.

here I have a short example

https://werner.rothschopf.net/microcontroller/202011_arduino_webserver_fetch_api_en.htm

Hello, Thank you for that. I'm trying to write it and I'm having a little trouble. I tried to write it like this.

client.println("client.println("<script> 
alert("Hi.");
</script>");

I'm not good at coding. But I'm not sure how?

Edit: I try to write it like this

client.println("client.println("<script>alert("Hi.");</script>"); 

and I'm getting an error saying missing " charactor.

Joseph

Thank you I'm taking a look at it.

Joseph

you have to either escape the quotation marks

client.println("<script>alert(\"Hi.\");</script>");

or use apostrophes/single quotes instead

client.println("<script>alert('Hi.');</script>");

Thank you very much. I was searching online and saw a problem with the Quotations marks. I did change them to single quotes and that did work. Again thank you very much.

Joseph

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.