我使用的是formwizard中的Dajaxice,它处于一个非常混乱的状态,因为它既不显示任何错误,也不显示输出。我的代码如下:
在阿贾克斯.py在
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
在网址.py在
^{pr2}$向导1.html
{% block head %}
{% dajaxice_js_import %}
<title>My base template</title>
<script type="text/javascript">
function my_callback(data){alert(data.message);alert("Hello");}
</script>
{% endblock %}
{% block content %}
<input type="button" onclick="Dajaxice.trusform.dajaxice.core.sayhello(my_callback)" value="Get message from server!">
{% endblock %}
Django项目
trustform
manage.py
trustform
ajax.py
forms.py
urls.py
settings.py
dajaxice
dajaxice.core.js
templates
wizard1.html
能否请您特别谈谈路径结构,特别是onclick方法,因为我怀疑这是由于错误的路径,但不确定。在
尝试更换
与
^{pr2}$因为
sayhello
方法是应用程序的一部分。另外,你在trustform中漏掉了“t”,所以也加上这个。在相关问题 更多 >
编程相关推荐