You are writing a comment about Two-Faced Django Part 5: JQuery Ajax, here is a quick summary:
Moving along in the Two-Faced-Django series, we look at using JQuery for Ajax in the webapp portion of our program.
You are responding to this comment written by batiste on January 3rd 2008, 23:33.
If you want to be unobstrusive and don't pollute the javascript namespace it's better to do something like this :
{% extends "web/base.html" %}
{% block title %} Poll: {{ object.question }} {% endblock %}
{% block body %}
<div id="poll">
<p>We have a question for you. {{ object.question }}
<p> So far we have {{ object.up_votes }} upvotes and {{ object.down_votes }} downvotes, for an overall vote of {{ object.score }}! </p>
<script type="text/javascript">
$(document).ready(
function () {
function vote() {
$.get(this.href, function(response){
alert("Was successful?: " + response);
});
}
$('#poll .vote').click(vote);
});
</script>
<p> Do you <a class="vote" href="{% url vote-up %}">agree</a> or <a href="{% url vote-down %}" class="vote">disagree</a>? </p>
</div>
{% endblock %}
Please be aware that comment forms go stale after one hour.
Comments may make use of LifeFlow MarkDown. Raw html will be escaped.
Quick Introduction to LifeFlow MarkDown Syntax
A highlighted code block:
Other common languages work as well: scheme, python, java, html, etc.
Other markdown syntax: