在为hello world工作一整天后,我似乎无法从Dajax得到一个简单的hello world响应。 (我相信你会发现这是来自你好世界指南的逐字逐句)
我有一个apps文件夹示例:proj / apps / myapp
我在myapp中创建了ajax.py:
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
我有我的模板:
{% load dajaxice_templatetags %}
<html>
<head>
<title>My base template</title>
...
{% dajaxice_js_import %}
</head>
<script type="text/javascript">
function my_js_callback(data){
alert(data.message);
}
</script>
<input type="button" onclick="Dajaxice.myapp.sayhello(my_js_callback);" value="test">
</html>
这不起作用。我也按照安装指南的字样找到了http://django-dajaxice.readthedocs.org/en/latest/installation.html
非常感谢任何帮助。我觉得我正在失去理智。
答案 0 :(得分:0)
OP的原始努力中省略了结束括号。