hello, i try to combine 5 charts + 4 gauges + 1 slider to adjust a PWM value I cant get the slider value ..error messages given in console one from index.html , the other from Script.js i don’t know where to search the issue…
index.html side :
Led Bleue (15)
PWM 15 :
%
script.js side:
function getCurrentValue1() {
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(‘pwmSlider1’).value = this.responseText
document.getElementById(‘textSliderValue1’).innerHTML = this.responseText
}
}
xhr.open(‘GET’, ‘/currentValue1’, true)
xhr.send()
}
function updateSliderPWM() {
var sliderValue1 = document.getElementById(‘pwmSlider1’).value
document.getElementById(‘textSliderValue1’).innerHTML = sliderValue1
console.log(‘update sliderValue1 : ‘)
console.log(sliderValue1)
// websocket.send(‘1s’ + sliderValue1.toString())
websocket.send(‘1s’ + sliderValue1)
}
Hi.
Is this the complete javascript code?
Can you share the complete code?
From that error code, it seems that websocket was not defined previously…
Regards,
Sara
hello Sara,
Thank’s for your answer.
all into this link , wich describe the project and program sources *.ino, *.js
projet ESP32
Hi.
You have this function to initialize websockets, but it is never called:
function onload(event) {
initWebSocket()
getCurrentValue1()
}
Change this:
window.addEventListener('load', getReadings)
to the following, so that the onload function is called at startup.
window.addEventListener('load', onload)
Then, if you also want to get readings, you need to add the getReadings function to the onload function too:
function onload(event) {
initWebSocket()
getReadings()
getCurrentValue1()
}
Regards,
Sara