function create_comment(){
data = $('.comment_form form').serializeObject();
Dajaxice.iwebs.create_comment(Dajax.process,{'content':data.content,'post_id':data.post_id});
return false;}`
In HTML form I use {% csrf_token %}
cookie. Django wants to use X-CSRFToken
https://docs.djangoproject.com/en/1.2/ref/contrib/csrf/#ajax How can I implement it?
My ajax.py
@dajaxice_register
def create_comment(request, content, post_id):
dajax = Dajax() /n dajax.alert('foobar') /n return dajax.json()
Dajaxice works correct but not at forms. The error is "Something goes wrong"
dajaxice works fine for me whenever I set {% csrf_token %}. Try this instead:
data = $('#<form_id>').serializeObject();
Dajaxice.iwebs.create_comment(Dajax.process,{'data':data});
please use firebug and see what error ur getting, 403 may mean csrf token issues while if u get 'Dajaxice Exception', it will be likely because of internal errors
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.