1👍
✅
All I had to do is set async option to false as part of the request parameters.
function select_row(row_selector, is_checked) {
is_box_checked = typeof is_checked !== 'undefined' ? is_checked : row_selector.checked;
request = {
url: "{% url 'set_check_box' %}",
type: "POST",
contentType: "application/x-www-form-urlencoded",
async: false,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
checked: is_box_checked,
check_box_id: row_selector.id,
type: row_selector.name
},
error: function(response, status, error_msg) {
console.log(error_msg);
}
};
$.ajax(request);
}
Source:stackexchange.com