[Fixed]-JsonResponse doesn't return data in template

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.

Leave a comment