AJAX AND JAVASCRIPT API INTEGERATION

AJAX AND JAVASCRIPT API INTEGERATION

Hello,I am developing an Inventory Management system webapp.My view is using data tables showing list of vendord,stores and admin .i have an delete and Edit icon.Iwant to integrate my api in these icons .

THE API'S ARE

1.Delete user by id using post method

2. Edit user using update method

I am using AJAX JQUERY Api Integration.

Please provide some help


Code is as follows:

 txt += "<a href='editsubadmin.html?id="+dd+"'><i class='fa fa-pencil fa-1x' aria-hidden='true'></i></a> | <a href='' onclick='delete_data("+dd+")'>";

                                                txt += "<i class='fa fa-trash fa-1x'aria-hidden='true'></i></a></td>";





 function delete_data() {

var obj, dbParam, xmlhttp, myObj, x,admin_ID

admin_ID=aa; console.log(admin_ID);

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange",function () {  if (this.readyState === 4) {     console.log(this.responseText);   } });

xhr.open("POST","API URL");

xhr.setRequestHeader("authorization", "Basic YWRtaW46MTIzNA==");

xhr.setRequestHeader("postman-token", "d99e506c-043e-fd5b-013e-8c81fedafb64");

xhr.send();