双面Django第5部分:jquery ajax

jquery(6), Django(72)

And, now we just need to make sure it works, and then we're done.

Verifying our progress

First, lets fire up the development server:

python manage.py runserver

And then navigate to the民意调查清单(除非您还没有创建任何民意调查,否则那么去这里创造一个民意调查。点击任何民意调查,您将Shold运送到该轮询的详细信息页面。

Now click on the text near the bottom of the screen labeled同意或者disagree。It should then popup a javascript alert saying something like "Was successful?: True". If you look at our piece of Javascript above, you can notice that JQuery is deserializing the returned JSON array, and we are checking it for the 'success' key (which we are returning via ourvote查看in.轮询ing/web/views.py)。

在此屏幕中,分数将无法激活,您需要返回to the list of polls看到更新的年代cores. (If anyone runs into trouble figuring out how to dynamically update the page, I can write another segment covering that, but it'll require at least one actual request. :) A snapshot of our current codecan be downloaded here

而且,我们完成了网页应用程序。Phew. We just need to立即开始编写Pyfacebook应用程序,在本教程的第六节中

顺便说一下,写作测试创造查看in.网页/views.py是一个非常好的主意。我会把它作为读者的锻炼,但希望我也会回来和演练。