Answer the question
In order to leave comments, you need to log in
How to load a script with Ajax in Django?
Question 1
In the base template, Django made 2 functions for Ajax requests
function ajax_get(url, block_id) {
$.ajax({
url: url,
type: 'GET',
dataType: 'html',
success: function (data) {
$(block_id).html(data);
}
})
}
function ajax_post(url, form_id, block_id) {
var form = $(form_id).serialize();
$.ajax({
url: url,
type: 'POST',
data: form,
dataType: 'html',
success: function (data) {
$(block_id).html(data);
}
});
return false;
}
$( document ).ready(function() {
loadScript("{% static 'js/plugin/bootstraptree/bootstrap-tree.min.js' %}");
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question