Loop through Array nodes = document.querySelectorAll('[id^=node]'); nodes.forEach((x, i) => x.dispatchEvent(new MouseEvent('mouseover', {'bubbles': true})));" Resource: https://stackoverflow.com/questions/3010840/loop-through-an-array-in-javascript
Submit POST request without reloading page As an added bonus, this will also print the response output to the DOM.
Do not run this in production - it has vulnerabilities in it.
<!doctype html> <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function () { // Create a compute node for the specified email and // return its public IP address. function createCompute() { // Handle the POST request and subsequent response data. $.ajax({ type: "POST", email: $("#email").val(), url: "https://awesomeendpoint.com?email=" + $("#userEmail").val() + "", crossDomain: true, xhrFields: { withCredentials: true, }, dataType: "text", success: function (data, textStatus, xhr) { if (textStatus === "success") { $("#responseDiv").html("<p>" + data + "<br>"); } }, error: function (data, textStatus, xhr) { if (textStatus != "success") { $("#responseDiv").html("<p>" + data.responseText + "<br>"); } }, }); } // Submit the createCompute Form $("#createCompute").submit(function (event) { // Prevent the form from submitting via the browser's default action. event.preventDefault(); createCompute(); }); }); </script> </head> <body> <!-- The form to specify parameters for building an ec2 instance for a user--> <form id="createCompute"> <input id="userEmail" type="hidden" name="email" value="bob@gmail.com" /> <button type="submit" class="btn btn-default">Build compute node</button> </form> <!-- Output Div --> <div id="responseDiv"></div> </body> </html> Resources:
...