1
Prevent the default click event
$('.list li a').on('click', Filtrar);
function Filtrar(e){
e.preventDefault();
var id = $(this).text()
$.ajax({
data : {'id' : id},
url : '/filtro/',
type : 'get',
success: function(data){
console.log(data);
}
});
};
return a json response
return JsonResponse({'name' : carrera.name, 'age' : carrera.summary})
0
I don’t know python but for you jquery ajax call i think
data : {'id' : '\"'+ id + '\"'},
instead of data : {'id' : id},
would solve your issue.
Because you are sending a string so you need to add it inside quotations sign.
- Why do balanced Django templating {% if %} and {% endif %} get Invalid block tag on line 50: 'endif', expected 'empty' or 'endfor'
- How to append more data in FormData for django?
- View with form and context dict
- Django and mysql on different servers performance
Source:stackexchange.com