itskp-odense/Frontend/Assets/Ajax/createUser.js

27 lines
825 B
JavaScript

function createUser(name, pass) {
var data = {
name: name,
password: pass,
};
$.ajax({
url: '../Backend/controller/createUser.php',
type: 'POST',
dataType: 'json',
data: data,
success: function (data) {
$('#table_id_users').DataTable().row.add([
name,
'<a class="w-1em" onclick="editUser('+ data + ')"><img src="Assets/Images/Icons/pencil-dark.svg" alt="Edit"></a>',
'<a class="w-1em" onClick="deleteUserSwal(' + data + ')"><img src="Assets/Images/Icons/trashcan-dark.svg" alt="Delete"></a>'
]).draw().node().id = data;
},
error: function (data) {
console.log("error");
console.log(data);
console.log("error");
}
});
}