I'm new to Drupal, I'm a designer heavily into front-end javascript development so I prefer to use AJAX calls for everything so as to never have to refresh the entire web page. I have been looking over the AJAX modules available for Drupal and I'm not sure that there is one trying to do what I want, I would appreciate any advice on this:
I want to make it so I can take the php calls / outputs (not sure what they're called) from a Drupal theme and place these into my javascript websites, however I would like to make it so that I can specify if certain elements of the page will not re-load, for example if there is no need to re-load a menu when loading a new node I would want to be able to specify to only re-load the node so as to save on server resources.
I don't know much about server side scripting so maybe this is already the case? But from what I can tell its re-loading all aspects of the page each time so if anyone can offer any advice I would appreciate it.
Comments
I'd like to do something similar
I have a custom "search box" and want to load a page when a certain term is typed. To use Drupal terminology, I would have a Drupal content block which has my custom search form and then another content block below that. When you type in "portfolio" i would like to make an AJAX call that would load my "portfolio" page into the second content block.
What needs to be done to make these types of AJAX calls?
Loading node content directly into an existing page element
I have also searched for something that does this. There are many modules that deal with Ajax calls, but none that handle the use case of loading Drupal page content into an existing element on the page.
I have created a module called Ajax Page which does just that. You can add "rel='ajax-page' " to any link on your page, and the content will be loaded into a pop-up div instead of taking the user to a new page. The pop-up can be styled as necessary.
The module adds javascript to the page that would allow you to replace content on any element on the page by calling $('#your-element').load('/ajax-page/node/id') in your own handler.
I won't upload this to the repository until I'm sure I haven't repeated anyone else's work, but if you want to check it out:
http://evolving-design.biz/ajax_page.tar.gz
Have you seen the "Ajaxify"
Have you seen the "Ajaxify" jquery plugin? It does not look that difficult to use, and would not require a drupal module to use...
http://maxblog.me/ajaxify/
-Blake
www.BlakeSenftner.com www.3D-Avatar-Store.com
This solves the problem of
This solves the problem of loading content into your element, as do many solutions I've seen.
The problem is when your content is Drupal specific. The common use case for this is:
User lands on home page.
User clicks to read an article on a news feed block showing headlines.
A window pops up showing the text of the article.
The user closes the window and goes on to something else on the same page.
If the user does not have js enabled, I want the click on the article to take them to that node's page, as is the normal case.
Easily done with $('#element-id').load('/node/32'); and I agree. But that causes Drupal to generate an entire page, complete with (probably redundant stylesheets, javascripts, etc.) In some cases, reloading scripts may actually interfere with what's going on currently on the page.
Much better to load just the node's content rather than the entire page. This is what Ajax Page does.
Ah... thanks for the
Ah... thanks for the clarification. Ajax Page sounds really useful. Thanks for developing it!
-Blake
www.BlakeSenftner.com www.3D-Avatar-Store.com
I have a idea to solve this problem
I have implemented this idea in wordpress. In wordpress I wanted to make ajax calls to retrive some pages. What i did was this.
Similarly, we can use the same method in drupal also. But I have no idea how to make ajax call in drupal. Idea is same, make a ajax call to a file, that file will have all the required code. We can use drupal functions like node_load() to fetch required node. Then all is in our hands, make a cutom HTML structure and echo it out.
If there is any other solution please help me out. Even I am trying to do the same thing.
Thanks... :)