The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Help with HTTP request 'Get', Display HEX data received correctly.
xtech007
post Oct 23 2020, 10:59 PM
Post #1





Group: Members
Posts: 4
Joined: 23-October 20
Member No.: 27,601



Hi All!
Thank you in advance for your valuable time.
This is my first Post but I have been reading lots for a while here.
I'm self taught, and thanks to forums and folks like you guys I have reached this far!

So, here is my issue:
I have a webpage with 2 html files. Page 1 and Page 2. Both request specific data from a device (Nodemcu) via serial.
When load page 1 will request data from a device and when received it will display it.
expected data is : 7d 03 18 07 05 00 00 00 00 00 00 96 00 00 00 39 00 00 00 8a 00 00 00 64 00 00 56 07.
and it works fine!
when I click on Page 2 it does the same and display its data as well correctly.
but when I click on page 1 again it will display the data Correctly once and then after its position changes to something like:
56 07 7d 03 18 07 05 00 00 00 00 00 00 96 00 00 00 39 00 00 00 8a 00 00 00 64 00 00.

This Only happens to page 1. I have tried to see if this happens to page 2 by doing the reverse but No, data always lines up.

I have attached html files & css files for review.
This is what I used on the request part:
CODE
setInterval(function() {
    Getstring();
  }, 3000);

  function Getstring(){
    var xhttp = new XMLHttpRequest();
    var page1;
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        page1 = String(this.responseText);
        document.getElementById("SENSORValue").innerHTML = page1;
      }
    };
    xhttp.open("GET", "/getDATA1", true);
    xhttp.send();
  }

when the device gets the getData1 it sends the requested Data.
Same with page 2:
CODE

setInterval(function() {
    Getstring();
  }, 3000);

function Getstring(){
  var xhttp = new XMLHttpRequest();
  var page2;
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      page2 = String(this.responseText);
      document.getElementById("SENSORValue").innerHTML = page2;
    }
  };
  xhttp.open("GET", "/getDATA2", true);
  xhttp.send();


Hope to hear your opinion!

This post has been edited by xtech007: Oct 23 2020, 11:04 PM


Attached File(s)
Attached File  data.zip ( 2.38k ) Number of downloads: 114
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 01:48 AM