0

在为 hello world 工作了一整天之后,我似乎无法从 Dajax 得到一个简单的 hello world 响应。(我相信你会意识到这是来自 hello world 指南的逐字逐句)

我有一个应用程序文件夹示例: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

任何帮助将不胜感激。我觉得我正在失去理智。

4

1 回答 1

0

OP 最初的努力中省略了右括号。

于 2014-01-01T19:13:27.390 回答