alexminichino/trawell

View on GitHub
src/main/resources/static/js/remove_itinerary.js

Summary

Maintainability
C
1 day
Test Coverage
/**
    * @author Alfieri Davide
    * this javascript delete an itinerary permanently */

$(document).ready(function(){
    $(".remove").click(function () {
        var wrapper = $("tr").filter($(this).parents());
        var id = $(this).attr("id");
        var url = "/api/itinerary/eliminate/"+id;

        custom_alert("Message","are you sure you want to eliminate this itinerary?")
        $.ajax({
            dataType: "text",
            url:url,
            headers:{
             'Accept' : 'application/json',
             'Content-Type' : 'application/json'
            },
            type:'POST',
            success:function(data){
                custom_alert("Message","success");
                wrapper.remove();
            },
           error:function(request,textStatus,errorThrown){
                custom_alert("Message","failed:");
            }
        });
        
     });
});