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()))
urlpatterns = patterns('', ('^$', index), ('^ajax/', ajax))
Передача данных JSON во внешний интерфейс с помощью Django