[Chicago] Django + AJAX

Kevin Boers KBoers at leapfrogonline.com
Mon Jun 4 21:26:47 CEST 2012


With regard to the 'polling' update of a specific div, I've usually done something like this:

     $(document).ready(function() {
       var refreshId = setInterval(function() {
       }, 2000);
       $.ajaxSetup({ cache: false });

That will call the django view on document ready, and then again every 2000ms. In this case, the view would return plain html, but you can use a similar method to poll for json and do something with it using callbacks. The jQuery docs are awesome; see load() and getJSON() for examples.


On Jun 4, 2012, at 1:52 PM, Bob Haugen wrote:

On Mon, Jun 4, 2012 at 1:26 PM, Oren Livne <livne at uchicago.edu<mailto:livne at uchicago.edu>> wrote:

Dear All,

What is the best practice of creating a django app with ajax? In
particular, polling (periodically updating a portion of a page) and updating
a portion upon an event (button click/link click/drop down menu).

Both of the features you mentioned depend mostly on Javascript - not
much on Django.  All of the popular js frameworks assist you in doing
ajaxy interactions.  The most popular among Django programmers I know
is Jquery, but Dojo also has a big Django following.

Besides the other places people suggested for searching, look in:
Chicago mailing list
Chicago at python.org

Kevin P. Boers
Senior Manager, Quality Assurance

Leapfrog Online
807 Greenwood
Evanston, IL  60201
Main 847-492-1968
Fax  847-492-1990
kboers at leapfrogonline.com<x-msg://107/kboers@leapfrogonline.com>

The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20120604/66fa4fcd/attachment.html>

More information about the Chicago mailing list