[Chicago] Django + AJAX

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


+1

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

    <script>
     $(document).ready(function() {
      $("#refreshing_div").load("django_view/");
       var refreshId = setInterval(function() {
         $("#refreshing_div").load("django_view/");
       }, 2000);
       $.ajaxSetup({ cache: false });
    });
    </script>

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.

Kevin

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:
http://groups.google.com/group/django-users/
and
http://stackoverflow.com/
_______________________________________________
Chicago mailing list
Chicago at python.org
http://mail.python.org/mailman/listinfo/chicago

Kevin P. Boers
Senior Manager, Quality Assurance
847-440-8381

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>
www.leapfrogonline.com<http://www.leapfrogonline.com/>


________________________________
CONFIDENTIALITY NOTE
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