Pete Jones Posted April 23, 2016 Share Posted April 23, 2016 Hi, I've got a long list of items to show. The list is a big table and when you click on a table row, additional information is shown (hidden table row). Part of this table row contains an image. Currently when I load the page, I'm loading all of the images too (not good), so I want to load the extra content onclick using AJAX. I'm using the delayed output model (_main.php/_init.php). How do I configure my templates so I can call a URL by AJAX and output the required content? Many thanks Pete Link to comment Share on other sites More sharing options...
DaveP Posted April 23, 2016 Share Posted April 23, 2016 This thread might help - https://processwire.com/talk/topic/225-how-to-work-with-ajax-driven-content-in-processwire/ 3 Link to comment Share on other sites More sharing options...
Pete Jones Posted April 23, 2016 Author Share Posted April 23, 2016 Neat. So for my page template I can put $config->ajax to check and render something else. The only problem is that I'm still returning the rest of my _main.php file. Can I prevent it loading for AJAX requests? Link to comment Share on other sites More sharing options...
arjen Posted April 23, 2016 Share Posted April 23, 2016 You can halt() like this: <?php if ($config->ajax) { // Do your stuff here echo 'Heard It Through The Grapevine'; // Call halt() to prevent further loading return $this->halt(); } 4 Link to comment Share on other sites More sharing options...
Pete Jones Posted April 24, 2016 Author Share Posted April 24, 2016 Nice to know. Very useful. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now