yes i did that now, and still doesnt work.. it still returns false and 
doesnt print the line after request.is_ajax()

On Monday, April 23, 2012 4:36:06 AM UTC+1, Amao wrote:
>
> dear psychok7:
>     You have no data from your ajax post, you should post some data with 
> your ajax post, like this 
> $.post("api/newdoc/", {'user':'your username'}, function(data) {
>         alert(data);
>     });
> }
>
> 在 2012年4月23日星期一,psychok7 写道:
>
>> hi there i am trying a simple example using AJAX, DJANGO, JQUERY, JSON 
>> and my if request.is_ajax() is not working for some reason.. here is my 
>> code:
>>
>> URLS: (r'api/newdoc/$', 'rose_miracle.views.newdoc'),
>>
>> VIEW:
>> def newdoc(request):
>>     # only process POST request
>>     print "entrei"
>>     if request.is_ajax():
>>         print "entrei2"                         _#this is not working
>>         data= dict(request.POST)
>>         print data
>>                 # save data to db
>>
>>         return HttpResponse(simplejson.dumps([True]))
>>         
>>     return HttpResponse(simplejson.dumps([False]))
>>
>> js:
>> $(document).ready(function(){
>>     
>>    
>> alert("ya");
>> $.post("api/newdoc/", function(data) {
>>         alert(data);
>>     });
>> }
>>
>>
>> i added this in a file as well, dont know how it works though 
>> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
>>
>> the print in my request.is_ajax()  is now working, what im i doing wrong??
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/J9sGcOB5wBwJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VLZFfoW8PtAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to