template.html
success: function (result, data) {
alert(result["val"]);
check = result[0]
alert(check);
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 200,
marginBottom: 75,
marginLeft: 70,
marginTop: 80,
width: 900
},
title: {
marginTop: 100,
text: result[4]
},
xAxis: {
categories: result[1]
},
{%if result.0 == "power" %}
yAxis: {
min: 0,
max: 30
},
}
{%else %}
yAxis: {
min: 0.85,
max: 1
},
{% endif %}
views.py
list_values.append("power")
list_values.append(m)
list_values.append(p)
list_values.append(q)
list_values.append(msg)
print list_values
response.content = json.dumps(list_values, cls=DjangoJSONEncoder)
return response
i am trying to plot the y axis based on the value i am sending from views. but it always goes to the else part. i am making a ajax request. How do i access the data i am passing from views in template where im using ajax.
It seems you are mixing Javascript, Django views and Django templates.
In the javascript success callback, you can only use objects from your json response. (I simplify)
success : function(result, data) {
// Dump objects
console.log(result);
console.log(data);
}
When your JSON response is correct, the javascript processing part has nothing to do with Django.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.