stingh711 发表于 2013-1-29 12:48:50

My first ajax app using django and jquery

Requirement:
There is a simple form that has two input field, one is zip code and another is city. If the zip code is filled, the page will fill the city automatically by getting the relevant city of the zip code in an AJAX way.

Implementation:
1. django-admin.py startproject study
2. cd study
3. python manage.py startapp ajax
4. Edit settings.py, add 'study.ajax' to INSTALLED_APPS.
5. mkdir site_media
6. Download jquery.js from www.jquery.com and copy it to site_media
7. Add the following line to urls.py:
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!---->(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root':'/home/sting/Django/study/site_media'}),
页: [1]
查看完整版本: My first ajax app using django and jquery