How to pass a value to MySQL from an infinitely looping Javascript function?
<p>I'm trying to write a simple web app that will read from a 1D barcode and insert the value to a MySQL database. </p>

<p>Ideally this website will access to a camera and just scan the barcodes, that are shown to it. There will be no further user interaction. </p>

<p>I have achieved scanning the barcodes and extracting the information in Javascript using ZXing. Now my research has shown me that you can't just insert a php inside javascript. So I must stop the infinite loop of the function and pass data to php, where it can be inserted to MySQL. However after I return from the function and update the database, I need to refresh the webpage to scan a new barcode. </p>

<p>The problem is here I don't want to refresh the webpage because the browser, that runs the webpage won't have any mouse/keyboard(user interaction). How can I call a javascript function infinite times without refreshing my browser?</p>