I’m currently in the midst of creating a generator which echoes a random line from a .txt file. All is well and good however I need to have this certain part of the page which echoes the random line refresh when a button is clicked. I’ve tried multiple methods to no avail and I’m running out of ideas – I’m still quite new to JavaScript/AJAX and have no idea on how to go about it. Any help would be brilliant, thanks!
Share
Use Jquery Ajax to get contents from the file and display the contents into a div
Bind click event of your button
Refreshing logic can be wrapped into a function and called on click of button OR you can use javascript settimeout method.