I have an array with a data dictionary in my session and would like to remove according to the line that the user is clicking on a table where those values are displayed.
My view:
def deletar_servico_ou_item_selecionado(request):
if request.is_ajax:
linhaClicada = request.POST.get('item')
lista = request.session['ord-serv']
del lista[linhaClicada - 1]
request.session['ord-serv'] = lista
return HttpResponse("/")
My JS:
var linhaClicada = $(this).parent().index();
$.ajax({
url: "/atendimento/deletar-servico-ou-item-selecionado/",
type: "POST",
data: {item: linhaClicada},
success: function(response) {
console.log("Success");
},
error: function(response) {
console.log("Error");
}
});
It seems that my value comes up to Django and I do not know if I should use type: "DELETE"
in that case.