21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 555 Views |
-
Simply load pages with AJAX - Tutorial?

25 December 2011 at 4:12am
I was wondering if there is any simple tutorial to load all pages via AJAX if JavaScript is present. The only thing I'd like to do is to not load the whole page (and the viewport to be white) when the user clicks onto a menu link. Has anybody done that yet?
Greatz
Oliver -
Re: Simply load pages with AJAX - Tutorial?

25 December 2011 at 7:56am
It's certainly doable but it's a rather bad idea. If you're switching from one page to another AJAX kind of loses it's purpose. The idea is to be able to switch or update certain elements of a page without having to make the whole round trip to the server but if you're loading a totally new page then that round trip is justified.
What you could do, if you're really really sure that you want to do this is to put an index() method in your controller. In that index method you check if Director::is_ajax() and if it is you just render the Layout template and not the rest. If it's not an AJAX request then you render all of it like you usually do.
-
Re: Simply load pages with AJAX - Tutorial?

25 December 2011 at 8:00am
I think that's exactly what I want to do. In this case, the page type is the same so all of the scripts, css-files and so on can be the same, only the content-box would have to be loaded. I'll try the index-function you mentioned. Thanks.
-
Re: Simply load pages with AJAX - Tutorial?

26 December 2011 at 8:27pm
I was same problem faced. now i have read these an solved.....
thanks for sharing....
| 555 Views | ||
|
Page:
1
|
Go to Top |


