// Paste your API Management gateway URL here (see AZURE_SETUP.md, step 8). No trailing slash. var API_ENDPOINT = "https://employeeapi.azure-api.net/employees"; document.getElementById("saveprofile").onclick = function () { var inputData = { empId: $("#empid").val(), empFirstName: $("#fname").val(), empLastName: $("#lname").val(), empAge: $("#empage").val(), }; $.ajax({ url: API_ENDPOINT, type: "POST", data: JSON.stringify(inputData), contentType: "application/json; charset=utf-8", success: function () { document.getElementById("profileSaved").innerHTML = "Profile Saved!"; }, error: function () { alert("error"); }, }); }; document.getElementById("getprofile").onclick = function () { $.ajax({ url: API_ENDPOINT, type: "GET", success: function (response) { $("#employeeProfile tr").slice(1).remove(); jQuery.each(response, function (i, data) { var row = $(""); // .text() escapes the value, so stored data can't inject HTML/JS row.append($("").text(data["empId"])); row.append($("").text(data["empFirstName"])); row.append($("").text(data["empLastName"])); row.append($("").text(data["empAge"])); $("#employeeProfile").append(row); }); }, error: function () { alert("error"); }, }); };