Example:
Template 1
<script>
function refresh_infos(element){
var id = "test"
$.ajax({
type: "POST",
url: '/part_update/',
data: {'id':id},
success: function(data) {
$('#testDIV').html(data);
}
});
}
</script>
<div id="testDIV"></div>
View
def part_update(request):
id = request.POST.get('id', "")
#/* get infomation */
infos = DB.objects.filter(id = id)
return render_to_response('supply/template.html', { 'infos': infos })
Template 2
{% for info in infos %}
<p>{{ info.id }}</p>
{% endif %}
Urls
adding:
(r'^/part_update/$','part_update'),
沒有留言:
張貼留言