The ajax() function documentation is here: 
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function
.

Note, the second argument does not do what you think it does. It should be 
an array of <input> element names (not div id's) that are on the current 
page (not on the page you are requesting via Ajax). The idea is that you 
can specify some form variables to pass along with the Ajax request. In 
this case, you can just use an empty array (i.e., []), since you you aren't 
passing any values.

To call the categories function without returning the full page layout, you 
might consider creating a separate no-layout view for the categories 
function that doesn't extend the layout (maybe call it categories.load). 
Assuming you want to re-use that view for the main categories page, you 
could then include it in the categories.html view:

{{extend 'layout.html'}}
{{include 'default/categories.load'}}

As an alternative, in your current categories.html, you could do:

{{extend 'layout.html' if not request.ajax else None}}

That will prevent extending the layout in case of an Ajax request, though 
in that case, that particular view will not be compileable.

Anthony

On Saturday, September 14, 2013 4:58:33 PM UTC-4, Avi A wrote:
>
>
> Hi,
> This is my link on the index page:
> {{extend 'layout.html'}}
> <div id="ajax_target">
> .........
> <a href="#" onclick="ajax('{{=URL('default', 'categories', args=(
> category.id))}}', ['ajax_content'], 
> 'ajax_target')">{{=category.f_category_name}}</a>
> ..........
> </div>
>
> where ajax_content is a div I want to display from the categories page, on 
> the index page.
> Categories page:
> {{extend 'layout.html'}}
> <div id="ajax_content">
> ......
> </div>
>
> It works as expected, except that it brings the whole categories page 
> (including the header and footer ), which is not expected.
> what should I do?
> Thanks.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to