JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" name="username" id="username" class="text" maxlength="30" />
<br />
<input type="password" name="password" id="password" class="text" maxlength="30" />
<br />
<input type="submit" name="btnSubmit" id="btnSubmit" />
JavaScript
$(document).ready(function () {
//event handler for submit button
$("#btnSubmit").click(function () {
//collect userName and password entered by users
var userName = $("#username").val();
var password = $("#password").val();
//call the authenticate function
authenticate(userName, password);
});
});
//authenticate function to make ajax call
function authenticate(userName, password) {
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: "http://isuite.c-entron.de/CentronService/REST",
dataType: 'json',
async: false,
//json object to sent to the authentication url
data: '{"Username": "' + userName + '", "Password" : "' + password + '"}',
success: function () {
//do any process for successful authentication here
}
})
}