{% load staticfiles %} {% for type in types %}
{{ type.name }}
{% endfor %}
script src=’{% static “js/jquery-1.10.2.min.js” %}’>
script src=’{% static “js/jquery.cookie.js” %}’>
div id=“content”>
script>
$(document).ready(function() {
$(“button”).click(function() {
$.ajax({
url: “/type/”,
type: “post”,
data: {
csrfmiddlewaretoken: $.cookie(“csrftoken”),
id: this.id
},
success: function(result) {
console.log(result); // json
result = JSON.parse(result); // 解析json
console.log(result[0]);
var str = “”;
for (let index = 0; index < result.length; index++) {
str += “
- ” + result[index][“fields”][“name”] + “
- ”;
}
$("#content").html(str);
}
});
});
});