0

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.

moreisee
  • 408
  • 8
  • 17
  • Are you properly serving the dajax static files? I believe `dajaxice_js_import` automatically checks if your static urls are correctly configured, but it can't hurt to verify it manually. Check your web console to see if its loading the dajaxice js properly. – Roman Alexander Sep 30 '13 at 00:12
  • @RomanAlexander Yep, I have it setup in the URLs to serve the files and I can see from runserver that it's pulling the static files appropriately. – moreisee Sep 30 '13 at 00:17
  • I'm an idiot. I forgot a closing bracket. Thanks @RomanAlexander for looking into it. – moreisee Sep 30 '13 at 00:29

1 Answers1

0

A closing bracket was omitted in the OPs original efforts.

demongolem
  • 9,474
  • 36
  • 90
  • 105