In a Django template, I have a function
function show_graph(i){
$("#"+i+"seegraph").click(function(){
$("#"+i+"graph").show();
var qaa = {{ question_ids }};
var qid = qaa[i-1];
jQuery.ajax({
url: "/canvas/recreatechart/",
type: "get",
data: {qid: qid },
success: function(response){
var resp = jQuery.parseJSON(response);
alert("chart1"+i);
show_graph("chart1"+i, resp['chart_type'], resp['series_names'], JSON.stringify(resp['data1']), resp['answer'], resp['stories1'], resp['colors'], resp['stacked'], resp['title1']);
show_graph(resp['second_graph']+i,resp['chart_type'], resp['series_names'], resp['data2'], resp['answer'], resp['stories2'], resp['colors'], resp['stacked'], resp['title2']);
}
});
});
}
and an alert immediately inside show_graph, from which I've deduced that show_graph just isn't getting called, but I don't know why.
I don't have any errors in my console, when I tried alerting each argument in the first call one by one, they all showed up as expected, although "data1" showed up as "object Object" with a type of "object" (When I stringified data1, it came out as expected, although I don't know if that means anything).
Note that data1 is an array of dictionaries, the values of which are arrays of arrays. So, slightly complicated, and I'm not sure if js can parse the structure.
Is that why my function is not getting called? If not, what is it? If so, how do I fix it (given that this is the format I have to pass my data in). How can I find the problem?
EDIT: I would also like to note that I just tested something simple like [5] in place of data1, as that's what I was afraid was messing up the function call, but I'm still not getting the alert from show_graph, so I think that's not it after all.