Hi. I have a python script that i run on my raspberry pi that would connect to a usb sensor and get a value each 0.5 seconds and output the results. I wanted to make a web app to view the data in realtime instead of using terminal so i thought of using cgi to load the python script and then use jquery with ajax to display it. But my question is how to get the page updated with the new output from the python script each 0.5 seconds

Member Avatar for diafol

You can use javascript to set an interval for calling the ajax script:

var setInt;

function startTimer(theInterval) {
    setInt = setInterval(ajaxFetch, theInterval);
}

function ajaxFetch()
{
    //ajax code
}

//When you want to start timer - if immediately, just do this:
startTimer(500);
//otherwise you can start it off a button click or whatever action you want.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.