Execute JavaScript on Submit Button

Building a simple form app, I choose an action of Execute JavaScript when the Submit button is clicked, dropped some code in (See Below) and tested, however when clicking the Submit button the JS does not seem to execute, Fiddler shows no POST action to the URL and the debug console doesn’t seem to indicate any activity. I added a 2nd activity of a page redirect and that does execute.

I am new to JavaScript but am I missing something ? http://elearnpoc.azurewebsites.net/sign-up

var url = “https://s1events.azure-automation.net/webhooks?token=mywebtoken”;
var method = “POST”;
// var postData = “Some data”;

// You REALLY want async = true.
// Otherwise, it’ll block ALL execution waiting for server response.
var async = true;

var request = new XMLHttpRequest();

// Before we send anything, we first have to say what we will do when the
// server responds. This seems backwards (say how we’ll respond before we send
// the request? huh?), but that’s how Javascript works.
// This function attached to the XMLHttpRequest “onload” property specifies how
_// the HTTP response will be handled. _
request.onload = function () {

_ // Because of javascript’s fabulous closure concept, the XMLHttpRequest “request”_
_ // object declared above is available in this function even though this function_
_ // executes long after the request is sent and long after this function is_
_ // instantiated. This fact is CRUCIAL to the workings of XHR in ordinary_
_ // applications._

_ // You can get all kinds of information about the HTTP response._
_ var status = request.status; // HTTP response status, e.g., 200 for “200 OK”_
_ var data = request.responseText; // Returned data, e.g., an HTML document._

request.open(method, url, async);

request.setRequestHeader(“Content-Type”, “application/json;charset=UTF-8”);
// Or… request.setRequestHeader(“Content-Type”, “text/plain;charset=UTF-8”);
// Or… whatever

// Actually sends the request to the server.


I think that your last code line should be:


Best Regards,

1 Like

Many Thanks that did the trick, seeing a POST request now and a 202 response from the webhook !