I have this form that a user choose values from two dropdown menu. The options in select comes from js file and are exchange rates list. I have already created the code that sho
I have solved it with help of Quentin. You guys can use this code, but remember to remove all of html that you have after your php code. it causes this error
Uncaught SyntaxError: row 23 Unexpected token < in JSON at position 4 at JSON.parse () at XMLHttpRequest.xhttp.onreadystatechange
if you get this, remove all of your html or anything you have after you echo the data you want to send to JS
<button onclick="loadDoc()" > show graph </button>
When the submit button is clicked, the loadDoc
function runs, but before the Ajax response arrives, the form submits and a new page is loaded.
The new page doesn't including the event handler waiting for the Ajax response.
Don't use a submit button. Add type="button"
.