[英]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.