Created
July 19, 2017 22:15
-
-
Save tristansokol/bafb1e1580c50176b2fa40752b993a60 to your computer and use it in GitHub Desktop.
sandbox dashboard blog post pt3 javascript funciton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteCustomer(element){ | |
if(!confirm('Are you sure you want to delete this customer?')){ | |
return false; | |
} | |
var location = document.getElementById('location-id').value; | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
if(this.responseText=='deleted'){ | |
alert('deleted'); | |
document.getElementById('table').removeChild(element.parentNode.parentNode) | |
}else{ | |
alert('something went wrong, check the console'); | |
} | |
console.log(this.responseText); | |
} | |
}; | |
xhttp.open("POST", "delete-customer.php", true); | |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
xhttp.send("customerId="+element.getAttribute('customerid')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment