dajax - Django server in one computer, client in other computer -
- i downloaded latest
django-dajaxice
zip file github unzip it. - then enter
django-dajaxice-master/examples
folder, run 'python manage.py runserver 13.122.241.172:80', (which computer's ip).
the server started normally. in server computer, can visit http13.122.241.172/ , page displays normally. click 'hello' button, can right response.
problem:
in collegue's computer, ip 13.122.242.16, can visit http13.122.241.172/
, but, when click 'hello' button, there no response!
debugging:
then check command window, see when click button, server never receive "get /dajaxice/simple.hello/?argv=undefined http/1.1
" request! confused problem , have been working on 3 days. me?
note:
- django version
1.4.20
. - django settings: debug=true.
my colleague can visit http://www.dajaxproject.com/dajaxice/ , if click 'get message server!' can server response.
code:
this relevant code dajaxice project:
index.html (template)
{% load dajaxice_templatetags %} <html> <head> {% dajaxice_js_import 'nocsrf' %} </head> <body> <button onclick="dajaxice.simple.hello(function(d){alert(d.message);})">hello</button> <button onclick="dajaxice.simple.bye(function(d){alert(d.message);})">bye</button> <button onclick="dajaxice.more.complex.bye(function(d){alert(d.message);})">complex bye</button> <button onclick="dajaxice.simple.lol(function(d){alert(d.message);})">lol</button> <button onclick="dajaxice.simple.get_args(function(d){alert(d.message);}, {'foo': 'var'})">get args</button> </body> </html>
ajax.py
import json dajaxice.decorators import dajaxice_register @dajaxice_register(method='get') @dajaxice_register(method='post', name='other_post') def hello(request): return json.dumps({'message': 'hello'}) @dajaxice_register(method='get') @dajaxice_register(method='post', name="more.complex.bye") def bye(request): raise exception("pummmm") return json.dumps({'message': 'bye'}) @dajaxice_register def lol(request): return json.dumps({'message': 'lol'}) @dajaxice_register(method='get') def get_args(request, foo): return json.dumps({'message': 'hello args %s' % foo})
progress:
- thanks topic. i'm newbie here. stackoverflow great place.
- now have found problem's crux: in server computer use ie11, in colleague's computer, uses ie9. if changes chrome, ok. still confuses me how should other people have ie9.
first thing try make sure ie9 has compatibility view turned off.
also please note author of django-dajaxice himself doesn't recommend using package:
in word, no. created project 4 years ago cool tool in order solve 1 specific problem had @ time.
these days using project bad idea.
perhaps i'm more pragmatic now, perhaps vision of how django projects should coupled libraries has change, or perhaps these days treasure purity , simplicity of vanilla django development.
if want mimic project does, need simple views , jquery.
forget adding more unnecessary complexity. keep things simple.
therefore consider if need dajaxice or can other way.
Comments
Post a Comment