I'm building a Django todo list. The checkboxes to mark a task as complete have ajax:
//Checkbox toggles
$('input:checkbox').click(function() {
if ($(this).attr('checked')) {
$action = true;
} else {
$action = false;
}
$.ajax({
type: "POST",
url: "/gtd/action/" + this.id.split("_")[1] + "/" + $(this).val() + "/" + $action + "/",
success: function(data) {
//Update entire gtd side menu
}
})
});
In the success portion of the ajax, I need to update multiple variables in a side menu (pertaining to the count of incomplete tasks). The django view can calculate the variables
def ajax_click(request, modelname, id, type, toggle):
#Do some stuff to save the object
action_count = actions = Action.objects.filter(complete=False, onhold=False).count()
hold_count = Action.objects.filter(onhold=True, hold_criteria__isnull=False).count()
return HttpResponse('')
The question is, how do I pass more than one variable back to the ajax function? In this instance, I have action_count and hold_count. How can I get these variables back to the success function?