I can't seem to get a simple hello world response from Dajax, after all day of working on hello world. (I'm sure you'll realize that this is word for word from the hello world guide)
I have an apps folder Example: proj/apps/myapp
I have created ajax.py inside of myapp:
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
I have my template:
{% 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>
This doesn't work. I have also followed the installation guide word for word found: http://django-dajaxice.readthedocs.org/en/latest/installation.html
Any help would be greatly appreciated. I feel like I'm losing my mind.
OP在最初的努力中省略了一个结束括号。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.