Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know anything about Zend(-controllers) but if you just want to load a1/a2/b1/b2.phtml I think this will help:</p> <p>Put the following code in the section of the page. It will need the jQuery library to be included.</p> <pre><code>&lt;script type="text/javascript" src="path/to/jquery-1.4.2.min.js"&gt;&lt;/script&gt; </code></pre> <p>The version doesn't have to be 1.4.2 but I've tested the code with that.</p> <p>I've put explanation in the comments.</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ // This function will be executed when the page is loaded jQuery('#linkA').click(loadInfoA); // Here a 'click' event is registered on the links jQuery('#linkB').click(loadInfoB); // When the user clicks on of the link the functions (loadInfoA, loadInfoB) will be executed }); function loadInfoA(event){ // This function will load the info from a1.phtml and a2.phtml event.preventDefault(); // This is to prevent the link (index/a) from being followed // Otherwise the user would be leaving the page and a1/a2.phtml wouldn't // be loaded into the divs jQuery.ajax({ // This is the main AJAX magic read more about it here: http://api.jquery.com/jQuery.ajax/ url: 'a1.phtml', // this is the page that will be loaded: a1.phtml success: function(data){ // this function will be executed when the data is loaded from the server jQuery('#one').html(data); // This will take div-one and put the from a1.phtml data in it } }); jQuery.ajax({ url: 'a2.phtml', // a2.phtml will be loaded success: function(data){ jQuery('#two').html(data); // This will take div-two and put the data from a2.phtml in it } }); } function loadInfoB(event){ // This function does the same as loadInfoA except that it will load b1/b2.phtml event.preventDefault(); jQuery.ajax({ url: 'b1.phtml', success: function(data){ jQuery('#one').html(data); } }); jQuery.ajax({ url: 'b2.phtml', success: function(data){ jQuery('#two').html(data); } }); } &lt;/script&gt; </code></pre> <p>I've edited your HTML slightly so that jQuery can register a click event on the links</p> <pre><code>&lt;a href='index/a' id="linkA"&gt;Load info A&lt;/a&gt; &lt;br/&gt; &lt;a href='index/b' id="linkB"&gt;Load info B&lt;/a&gt; &lt;br /&gt; &lt;div id="one"&gt;load first here&lt;/div&gt; &lt;div id="two"&gt;load second here&lt;/div&gt; </code></pre> <p>PS: This is my first contribution on Stack Overflow. Please let me know if it was helpful, or what could be improved</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload