<p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>

<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>

[{'answer_id': 54008, 'author': 'David Webb', 'author_id': 3171, 'author_profile': 'https://Stackoverflow.com/users/3171', 'pm_score': 5, 'selected': True, 'text': '<p>As Google Web Toolkit is a <a href="http://code.google.com/support/bin/answer.py?answer=54830&amp;topic=10208" rel="nofollow noreferrer">subset of Java</a> it works best when you Java at the backend too.  Since Google App Engine is currently <a href="http://code.google.com/appengine/kb/general.html#language" rel="nofollow noreferrer">Python only</a> I think you\'d have to do a lot of messing about to get your server and client to talk nicely to each other.</p>\n\n<p>jQuery seems to be the most popular JavaScript library option in the <a href="http://www.djangosnippets.org/tags/ajax/?page=1" rel="nofollow noreferrer">AJAX Tag at DjangoSnippets.com</a>.</p>\n\n<p><strong>Edit:</strong> The above is only true of Google App Engine applications written in Python.  As Google App Engine now supports Java, GWT could now be a good choice for writing an AJAX front end.  <a href="http://code.google.com/webtoolkit/doc/latest/tutorial/appengine.html" rel="nofollow noreferrer">Google even have a tutorial showing you how to do it.</a></p>\n'}, {'answer_id': 54015, 'author': 'Tim Howland', 'author_id': 4276, 'author_profile': 'https://Stackoverflow.com/users/4276', 'pm_score': 2, 'selected': False, 'text': "<p>I'd recommend looking into a pure javascript framework (probably Jquery) for your client-side code, and write JSON services in python- that seems to be the easiest / bestest way to go.</p>\n\n<p>Google Web Toolkit lets you write the UI in Java and compile it to javascript. As Dave says, it may be a better choice where the backend is in Java, as it has nice RPC hooks for that case.</p>\n"}, {'answer_id': 54034, 'author': 'Christian Oudard', 'author_id': 3757, 'author_profile': 'https://Stackoverflow.com/users/3757', 'pm_score': 1, 'selected': False, 'text': '<p>jQuery is a fine library, but also check out the <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype JavaScript framework</a>. It really turns JavaScript from being an occasionally awkward language into a beautiful and elegant language.</p>\n'}, {'answer_id': 55041, 'author': 'Christian Berg', 'author_id': 5035, 'author_profile': 'https://Stackoverflow.com/users/5035', 'pm_score': 2, 'selected': False, 'text': '<p>There is no reason why you shouldn\'t use GAE and Google Web Toolkit (GWT) together. You write your backend code in Python and the frontend code in Java (and possibly some JavaScript), which is then compiled to JavaScript. When using another AJAX framework you will also have this difference between server and client side language.</p>\n\n<p>GWT has features that make remote invocation of java code on the server easier, but these are entirely optional. You can just use JSON or XML interfaces, just like with other AJAX frameworks.</p>\n\n<p>GWT 1.5 also comes with JavaScript Overlay Types, that basically allow you to treat a piece of JSON data like a Java object when developing the client side code. You can read more about this <a href="http://googlewebtoolkit.blogspot.com/2008/08/getting-to-really-know-gwt-part-2.html" rel="nofollow noreferrer">here</a>.</p>\n\n<p><strong>Update:</strong></p>\n\n<p>Now that Google has added Java support for Google App Engine, you can develop both backend and frontend code in Java on a full Google stack - if you like. There is a nice <a href="http://code.google.com/eclipse/" rel="nofollow noreferrer">Eclipse plugin</a> from Google that makes it very easy to develop and deploy applications that use GAE, GWT or both.</p>\n'}, {'answer_id': 62976, 'author': 'Steve', 'author_id': 7424, 'author_profile': 'https://Stackoverflow.com/users/7424', 'pm_score': 0, 'selected': False, 'text': '<p>If you want to be able to invoke method calls from JavaScript to Python, <a href="http://json-rpc.org/wiki/python-json-rpc" rel="nofollow noreferrer">JSON-RPC</a> works well with Google App Engine.  See Google\'s article, "<a href="http://code.google.com/appengine/articles/rpc.html" rel="nofollow noreferrer">Using AJAX to Enable Client RPC Requests</a>", for details.</p>\n'}, {'answer_id': 230476, 'author': 'o2bjang', 'author_id': 16380, 'author_profile': 'https://Stackoverflow.com/users/16380', 'pm_score': 0, 'selected': False, 'text': "<p>I'm currently using JQuery for my GAE app and it works beautifully for me. I have a chart (google charts) that is dynamic and uses an Ajax call to grab a JSON string. It really seems to work fine for me.</p>\n"}, {'answer_id': 352120, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>You may want to have a look at Pyjamas (<a href="http://pyjs.org/" rel="nofollow noreferrer">http://pyjs.org/</a>), which is "GWT for Python". </p>\n'}, {'answer_id': 605156, 'author': 'mahmoud', 'author_id': 72931, 'author_profile': 'https://Stackoverflow.com/users/72931', 'pm_score': 2, 'selected': False, 'text': '<p>Here is how we\'ve implemented Ajax on the Google App Engine, but the idea can be generalized to other platforms.</p>\n\n<p>We have a handler script for Ajax requests that responds -mostly- with JSON responses. The structure looks something like this (this is an excerpt from a standard GAE handler script):</p>\n\n<pre><code>def Get(self, user):\n    self.handleRequest()\n\ndef Post(self, user):\n    self.handleRequest()\n\n\ndef handleRequest(self):        \n    \'\'\'\n    A dictionary that maps an operation name to a command.\n    aka: a dispatcher map.\n    \'\'\'\n    operationMap = {\'getfriends\':               [GetFriendsCommand],\n                    \'requestfriend\':            [RequestFriendCommand, [self.request.get(\'id\')]],\n                    \'confirmfriend\':            [ConfirmFriendCommand, [self.request.get(\'id\')]],\n                    \'ignorefriendrequest\':      [IgnoreFriendRequestCommand, [self.request.get(\'id\')]],\n                    \'deletefriend\':             [DeleteFriendCommand, [self.request.get(\'id\')]]}\n\n    # Delegate the request to the matching command class here.\n</code></pre>\n\n<p>The commands are a simple implementation of the command pattern:</p>\n\n<pre><code>class Command():\n    """ A simple command pattern.\n    """\n    _valid = False\n    def validate(self):\n        """ Validates input. Sanitize user input here.\n        """\n        self._valid = True\n\n    def _do_execute(self):\n        """ Executes the command. \n            Override this in subclasses.\n        """\n        pass\n\n    @property\n    def valid(self):\n        return self._valid\n\n    def execute(self):\n        """ Override _do_execute rather than this.\n        """ \n        try:\n            self.validate()\n        except:\n            raise\n        return self._do_execute()\n\n    # Make it easy to invoke commands:\n    # So command() is equivalent to command.execute()\n    __call__ = execute\n</code></pre>\n\n<p>On the client side, we create an Ajax delegate. Prototype.js makes this easy to write and understand. Here is an excerpt:</p>\n\n<pre><code>/** \n * Ajax API\n *\n * You should create a new instance for every call.\n */\nvar AjaxAPI = Class.create({\n    /* Service URL */\n    url: HOME_PATH+"ajax/",\n\n    /* Function to call on results */\n    resultCallback: null,\n\n    /* Function to call on faults. Implementation not shown */\n    faultCallback: null,\n\n    /* Constructor/Initializer */\n    initialize: function(resultCallback, faultCallback){\n        this.resultCallback = resultCallback;\n        this.faultCallback = faultCallback;\n    },\n\n    requestFriend: function(friendId){\n        return new Ajax.Request(this.url + \'?op=requestFriend\', \n        {method: \'post\',\n         parameters: {\'id\': friendId},\n         onComplete: this.resultCallback\n        });     \n    },\n\n    getFriends: function(){\n        return new Ajax.Request(this.url + \'?op=getfriends\', \n        {method: \'get\',\n         onComplete: this.resultCallback\n        });    \n    }\n\n});\n</code></pre>\n\n<p>to call the delegate, you do something like:</p>\n\n<pre><code>new AjaxApi(resultHandlerFunction, faultHandlerFunction).getFriends()\n</code></pre>\n\n<p>I hope this helps!</p>\n'}, {'answer_id': 800037, 'author': 'Scott Kirkwood', 'author_id': 95818, 'author_profile': 'https://Stackoverflow.com/users/95818', 'pm_score': 3, 'selected': False, 'text': '<p>A nice way is to use an AJAX library is to take advantage of <a href="http://code.google.com/apis/ajaxlibs/" rel="nofollow noreferrer">Google\'s AJAX Libraries API service</a>.  This is a bit faster and cleaner than downloading the JS and putting it in your <code>/static/</code> folder and doesn\'t eat into your disk quota.</p>\n\n<p>In your javascript you would just put, for example:</p>\n\n<pre><code>google.load("jquery", "1.3.2");\n</code></pre>\n\n<p>and/or</p>\n\n<pre><code>google.load(google.load("dojo", "1.3.0");\n</code></pre>\n\n<p>Somewhere in your header you would put something like:</p>\n\n<pre><code>&lt;script src="http://www.google.com/jsapi?key=your-key-here"&gt;&lt;/script&gt;\n</code></pre>\n\n<p>And that\'s all you need to use Google\'s API libraries.</p>\n'}, {'answer_id': 800072, 'author': 'levik', 'author_id': 4465, 'author_profile': 'https://Stackoverflow.com/users/4465', 'pm_score': 0, 'selected': False, 'text': '<p>Google has recently announced the Java version of Google App Engine. This release also provides an Eclipse plugin that makes developing GAE applications with GWT easier.</p>\n\n<p>See details here: <a href="http://code.google.com/appengine/docs/java/overview.html" rel="nofollow noreferrer">http://code.google.com/appengine/docs/java/overview.html</a></p>\n\n<p>Of course, it would require you to rewrite your application in Java instead of python, but as someone who\'s worked with GWT, let me tell you, the advantages of using a modern IDE on your AJAX codebase are totally worth it.</p>\n'}, {'answer_id': 994994, 'author': 'dfa', 'author_id': 89266, 'author_profile': 'https://Stackoverflow.com/users/89266', 'pm_score': 2, 'selected': False, 'text': '<p>try also <a href="http://ajaxian.com/archives/gquery-java-gwt-and-jquery-together" rel="nofollow noreferrer">GQuery for GWT</a>. This is Java code:</p>\n\n<pre><code>public void onModuleLoad() { \n    $("div").css("color", "red").click(new Function() { \n        public void f(Element e) { \n            Window.alert("Hello"); \n            $(e).as(Effects).fadeOut(); \n        } \n    }); \n} \n</code></pre>\n\n<p>Being Java code resulting in somewhat expensive compile-time (Java->JavaScript) optimizations and easier refactoring.  </p>\n\n<p>Nice, it isn\'t?</p>\n'}]
['https://Stackoverflow.com/questions/53997', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3834/']