我似乎不能从Dajax那里得到一个简单的hello world响应,因为我花了一整天的时间来研究hello world。(我相信你会意识到这是来自hello world指南的一字不差)
我有一个应用程序文件夹示例: proj/ apps /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
任何帮助都将不胜感激。我觉得我快疯了。
发布于 2014-01-02 03:13:27
在行动最初的工作中省略了一个结束括号。
https://stackoverflow.com/questions/19084090
复制相似问题