I have the following code:
$("#submit_financials").live('click', function(event){
event.preventDefault();
// using serialize here to pass the POST variables to the django view function
var serialized_data = $("#financials_filter_form").serialize()
$.post("/ajax/custom_filter/", serialized_data, function(response){
// create a graph
});
$.post("/ajax/force_download/", serialized_data, function(response){
alert('hello');
});
});
However, when I do this code, I get the response 'hello' before the graph. Why is this happening? And how would I change this such that I get the graph first?
custom_filterseems to take longer to process on the server so thatforce_downloadreturns first and invokes your callback.