P粉4038048442023-08-18 10:45:59
You have two options here, depending on your preference.
Return a template instead of JSON The idea here is to generate the template on the server side and then return the generated HTML to the AJAX caller. So Ajax success is just appending this HTML fragment to the correct location.
Render div in JS If you only have a JSON strategy or use DRF, the only way is to use a loop to loop through the received items and generate the equivalent HTML and then add it to the document.
You can't put JinJa on the same page because when you generate the page to render it, you haven't received the data yet.