On Friday, May 6, 2011 1:19:55 AM UTC-4, 黄祥 wrote: 
>
> <script> 
> jQuery(document).ready(function(){ 
>     jQuery('.view').click(function(){ajax('{{=request.controller}}', 
> [page + 1], 'comments')});

 
I don't think this will work as expected. The second argument to the ajax() 
function is supposed to be a list of IDs of fields on the page, not simply a 
variable you want to pass to the URL (
http://web2py.com/book/default/chapter/10#The-ajax-Function). Also, rather 
than request.controller (which refers to the entire controller file), you 
probably want request.function (which is the specific function/action 
called). So, maybe something like:
 
ajax('{{=URL(request.function, args=[page+1,])}}, [], 'comments')
 
 

> <div class = "comments"> 
> {{for i, row in enumerate(rows):}} 
> {{if i == items_per_page: break}} 
> {{=row.title}} 
> {{=BR()}} 
> {{pass}} 
> </div>

 
I don't think the above will work. The ajax() function is going to do its 
work on the client side in Javascript, so once the ajax call returns some 
HTML, the ajax() function will just insert it in the target DIV -- you 
cannot have Python doing anything at that point. You could move the Python 
code to the controller, and have it return the final HTML to go into the 
DIV.
 
Actually, have you thought about just doing this with components: 
http://web2py.com/book/default/chapter/13#Components?
 
Anthony

Reply via email to