script.js 613 B

1234567891011121314151617181920212223
  1. /**
  2. * Deletes a post from the database.
  3. *
  4. * @param id Post id.
  5. * @param title Post title.
  6. */
  7. function delete_post(id, title){
  8. if (confirm("Seguro que deseas borrar el post '" + title + "'? Esta accion es irreversible.")){
  9. var xmlhttp;
  10. if (window.XMLHttpRequest){
  11. xmlhttp=new XMLHttpRequest();
  12. }
  13. xmlhttp.onreadystatechange=function(){
  14. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  15. location.reload();
  16. }
  17. }
  18. xmlhttp.open("GET","/blog/delete/delete.php?p=" + id, true);
  19. xmlhttp.send();
  20. }
  21. }