5

I want to have a browser page that updates some information on a timer or events. I'd like to use Python on the server side. It's quite simple, I don't need anything massively complex.

I can spend some time figuring out how to do all this the "AJAX way", but I'm sure someone has written a nice Python library to do all the heavy lifting. If you have used such a library please let me know the details.

Note: I saw how-to-implement-a-minimal-server-for-ajax-in-python but I want a library to hide the implementation details.

5
  • What do you mean by "Ajax Library"? Javascript for Ajax? Or a web server for your Ajax transactions? Commented Apr 2, 2009 at 14:12
  • 1
    @S.Lott: I think he means server side handling since he mentions python Commented Apr 2, 2009 at 14:15
  • @Brian R. Bondy: Very likely true. However, the "hiding implementation details" could mean anything. And "AJAX library" often means JavaScript side of AJAX -- first hit on a Google search of AJAX Library is Yahoo User Interface Library. Commented Apr 2, 2009 at 15:06
  • ha! Sorry for the confusion. I'll clarify the question information. Sorry! Commented Apr 6, 2009 at 10:15
  • 1
    I'm using Web2py with Pyjamas. web2py.com/AlterEgo/default/show/203 Web2py's json handles AJAX comms and its been a joy writing browser client code in Python rather than native Javascript. Commented Aug 15, 2009 at 9:16

3 Answers 3

5

AJAX stands for Asynchronous JavaScript and XML. You don't need any special library, other than the Javascript installed on the browser to do AJAX calls. The AJAX requests comes from the client side Javascript code, and goes to the server side which in your case would be handled in python.

You probably want to use the Django web framework.

Check out this tutorial on Django tips: A simple AJAX example.

Here is a simple client side tutorial on XmlHTTPRequest / AJAX

Sign up to request clarification or add additional context in comments.

1 Comment

You'd think there's no need for special library, but all the articles and tutorials seem to depend one one or more behemoth libraries.
5

You can also write both the client and server side of the ajax code using python with pyjamas:

Here's an RPC style server and simple example:

http://www.machine-envy.com/blog/2006/12/10/howto-pyjamas-pylons-json/

Lots of people use it with Django, but as the above example shows it will work fine with Pylons, and can be used with TurboGears2 just as easily.

I'm generally in favor of learning enough javascript to do this kind of thing yourself, but if your problem fits what pygjamas can do, you'll get results from that very quickly and easily.

1 Comment

Yes, that looks along the lines of what I want. I shall investigate further. Cheers!
1

I suggest you to implement the server part in Django, which is in my opinion a fantastic toolkit. Through Django, you produce your XML responses (although I suggest you to use JSON, which is easier to handle on the web browser side).

Once you have something that generates your reply on server side, you have to code the javascript code that invokes it (through the asynchronous call), gets the result (in JSON) and uses it to do something clever on the DOM tree of the page. For this, you need a JavaScript library.

I did some experience with various javascript libraries for "Web 2.0". Scriptaculous is cool, and Dojo as well, but my absolute favourite is MochiKit, because they focus on a syntax which is very pythonic, so it will hide you quite well the differences between javascript and python.

1 Comment

Not sure I need a whole server framework like Django. Mochikit looks very interesting as I only need the AJAX functionality. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.