jQuery Code Sample to request Data AJAX
$(document).ready(function() { $.getJSON(‘/users’, function(data) { console.log(data); }); $(‘.btn’).click(function() { var user = $(‘input[name=”user”]’).val(); var pass = $(‘input[name=”pass”]’).val(); $.post(‘/users’, $(‘#myform’).serialize()) .done(function(data) { console.log(data); }); }); }); This code will make a GET request to /users endpoint when the page is loaded, and make a POST request to the same endpoint when the button with class btn … Read more