I am a beginner. I have the following code on a HTML page that calls an API and then executes a callback function which opens a Thank You URL that is dynamically created. It works fine:
<script>
function callback_function() {
// Dynamically compose thankYouURL (this is working fine)
window.location.href = thankYouUrl;
};
</script>
<script src='https://www.example.net/api/?parameter=example&callback=callback_function'>
</script>
However, I only want to execute that API code when the user presses a button.
To do that, I have removed the above "
How do I modify the following form so that the API is called and then calls the callback function when completing, just like when executing the API directly without a form.
<form method="GET" action="https://www.example.net/api" >
<input type="hidden" name="parameter" value='example'>
<input type="hidden" name="callback" value="callback_function">
<button type="submit">Click here</button>
</form>