Long, slow operation in Django view causes timeout. Any way for Python to speak AJAX instead? -


I was programming in a while, but in general, Django and web programming are new to me.

I have a very long operation done in Python View. Since the local () function takes so long to return to my idea, an HTTP timed out is sufficiently reasonable, I understand that part.

What is the best way to give an HTTPresponse back to my users immediately, then the results of some Python codes have been shown dynamically within the page? I suspect that the answer may be in AJAX, but I'm not sure that AJAX can be fed on the server by Python on the client, or even such modules can also be used to do this generally.

Ajax does not require any special technology on the server side. You just need to give feedback in some forms, which can understand some javascript on the client side. JSON is an excellent choice, because it is made in Python (2.6 has a json library, and for other versions, there is django.utils.simplejson in the projector).

So you just have to put your data into JSON form, so send it like any other response - that is by wrapping it in HTTPResponse .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -