[英]Dajax Hello World
经过一整天的hello world工作之后,我似乎无法从Dajax得到一个简单的hello world反应。 (我相信您会意识到,这是来自“ hello world guide”的逐字逐句说明)
我有一个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
任何帮助将不胜感激。 我感觉好像迷失了方向。
OP在最初的努力中省略了一个结束括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.