I am a seasoned developer with C#, JAVA, and C/C++ experience, but mostly worked on non-web apps/processes.
I have picked up Python and Django in the last couple months for my own project. I am at the stage of needing some AJAX elements for my web app. I know only the very basic of JavaScript, let alone AJAX.
Please recommend some resources for me to learn how to use AJAX with Django, let it books and/or online materials. Note that my plan is to use JQuery as my javascript library. Thanks.
<3 AJAX & Django! Very fun. Dajax tries to make working with ajax easier (although it's pretty easy to begin with). Here are a couple more blog posts:
And, here is a simple example you can play with (use in urls.py):
import json
from django.http import HttpResponse
from django.template import Template, Context
def ajax(request):
"""returns json response"""
return HttpResponse(json.dumps({'foo': 'bar'}), mimetype='application/json')
def index(request):
"""simple index page which uses jquery to make a single get request to /ajax, alerting the value of foo"""
t = Template("""
<!doctype html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
$.get('/ajax/', function(data) {
alert(data['foo']);
});
</script>
</head>
</html>""")
return HttpResponse(t.render(Context()))
# urlconf
urlpatterns = patterns('',
(r'^$', index),
(r'^ajax/', ajax),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With