[Answer]-What kind of response should I return from a simple django AJAX view?

1๐Ÿ‘

โœ…

If you respond with a json dump, then you can process it in js like this:

$.get(targetURL).done(function(data) {
  $.each(data, function(i,d) {
    $("#results").append($("<tr><td>" + d.name + "</td></tr>"));
  });
});

Or like this:

$.get(targetURL).done(function(data) {
  $("#results").append(data.map(function(i,d) {
    return $("<tr><td>" + d.name + "</td></tr>");
  }));
});
๐Ÿ‘ค000

Leave a comment