Dajax 不工作,我不明白为什么。我正在使用 Django 1.7
我的 ajax.py 文件如下所示:
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def jmc_foundation_tower_number(request, option):
print("It works!")
我的模板调用如下:
<div class='col-lg-3'>
<select id='id_tower_number' name='tower_number' onchange="Dajaxice.core.views.jmc_foundation_tower_number(Dajax.process, {'option':$this.value})" onclick="Dajaxice.core.views.jmc_foundation_tower_number(Dajax.process, {'option':$this.value})" class='form-control'>
{% for tower in towers %}
<option value='{{ tower }}'>{{ tower }}</option>
{% endfor %}
</select>
</div>
我的 urls.py 如下:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from dajaxice.core import dajaxice_autodiscover, dajaxice_config
dajaxice_autodiscover()
urlpatterns = patterns('',
url(r'^index$', 'core.views.index', name='index'),
url(r'^admin/', include(admin.site.urls)),
url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
)