Jump to content

processing two different ajax calls


fira
 Share

Recommended Posts

hey everyone,

I use delayed output and a basic ajax structure, see below. My page has four containers: content, shows, header & footer. Any show that is clicked is now being loaded in the content area. Works great! 

Now I would like to have certain links to load in the show container, instead of the content container. Could anyone give me a hint how i could achieve that? I think i need two different ajax calls..?

I need this to implement a sort function for the shows. I want to use $pages->get("/shows/")->children('sort=$sortvar'); 

 

thank you for your time!

fira

 

 

 

<?php
$cajax = $config->ajax;
if(!$cajax): 
			include("_head.inc");
?>

<!-- content -->
<div id="content">
<?php	
  endif; // end if ajax
?>
	<?=$content?>	      
<?php
if(!$cajax):
?>
</div>	<!-- //content -->

<div id="shows">
  <a href="sortshows=location">sort by location</a>
  <a href="">show link</a>
</div><!-- end shows -->

<div id="footer">
</div>

<?php endif; // end if ajax ?>

 

Link to comment
Share on other sites

Welcome to the forums @fira.

A bit difficult to answer your question without get the full information. Strictly speaking, this is a JavaScript question. Before getting into whether you should use 2 ajax calls or not, IMHO, it is more important to ask whether, in the first place, you need to use ajax at all? I am not questioning your abilities; just wondering if you haven't considered that question, then it may be important to do so. If you will be running a high traffic site, your server can easily be brought to its knees with ajax hits. Some ways to mitigate that include caching your data, if possible, both client- and server-side. That way, data is sent only once. Of course, this depends on your implementation. In your particular case, the key question is what is $sortvar? If you will be getting the same children, only sorted differently, then you might want to consider doing that client-side.

OK, back to your main question about using 2 ajax calls. If you take that route, the above considerations apply. Alternatively, if possible, load everything that is needed beforehand into a cache or hidden element, then use jQuery or similar to show [aka load] the links you want on demand in the different containers.

A final thing, using $page->children() without a limit is not recommended unless you will only ever be dealing with a handful of pages (maybe 50 - 100).

Hope this helps :).

  • Like 3
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...