Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

delete request from the script to html

// importing elemenets from html
let deleteEl = document.getElementById("delete");
let deleteInputEl = document.getElementById("deleteInput")
let deletResultsEl = document.getElementById("deleteResults")


const display = (data) =>{
  // data = JSON.stringify(data)
  for(let each of data){
    let para = document.createElement('p')
    each = JSON.stringify(each)
    para.innerHTML = each
    getResultel.appendChild(para)
  }
}

const deleteMethod = () =>{
        let url = deleteInputEl.value;
        let options = {
            method: "DELETE"
        };
        fetch(url, options)
            .then(function(response) {
                alert("Data deleted successfully")
            })
            
}

deleteEl.addEventListener("submit", function(event){
    event.preventDefault();
    deleteMethod();
  });
 
PREVIOUS NEXT
Tagged: #delete #request #script #html
ADD COMMENT
Topic
Name
8+2 =