Tuesday, October 11, 2011

Trivial view sometimes fails in Chrome

Simple view, shown below, sometimes fail in Chrome browser (request is shown as Pending or doesn't return any content):

def exposer(request):
    return HttpResponse('Response from AJAX exposer')

That is called by AJAX, eg:
$.post('{% url exposer %}', {'bb':'aa'}, callback);

Suprisingly if I change my view to:

def exposer(request):
    request.POST  # yes, just call it
    return HttpResponse('Response from AJAX exposer')

it works properly. 

Also, If I don't send any data with my POST request it works:
$.post('{% url exposer %}', {}, callback);

Problem exists only in Chrome browser and in WSGI environment (I've checked with uWSGI and Cherokee, Django 1.3 and trunk).

Example application that exposes the problem:

Live version of this application at: 
http://chrometest.natcam.pl (clicking first button sometimes fails in Chrome).

Application might be installed with:
python bootstrap.py --distribute
bin/buildout
bin/django syncdb

Above will install uwsgi at bin/uwsgi, and uWSGI can be run with:

 bin/uwsgi -b 8192  -s 127.0.0.1:1088 -p 1 -z 15 -l 128 --wsgi-file bin/django.wsgi


Any ideas what happens? Why does use of request.POST change behaviour?

--
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/-/TvqD6b711RgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment