I'm trying to refresh a subtemplate by calling a view with js. Nothing seems to happen, though the server gets hit and seems to return a response.
The goal is to refresh the included part without refreshing the whole page.
Minimal example:
views.py
def ajax_view(request):
context = {}
context['data'] = 'data'
return render(request, "test.html", context)// <-- reaches here, but no rendering
test.html
{{data}}
main.html
<script type="text/javascript">
function getQuery() {
var request = new XMLHttpRequest(),
method = 'GET',
url = '/ajax/';
request.open(method, url);
request.send();
}
</script>
{% include "test.html" %} // <-- does not update