Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unless the HTML files supposed to change somehow during their displaying, should either output them via your server-side code in hidden <code>div</code>s with the request (would be the correct way of doing it) or use AJAX to save them in a variable or create hidden <code>div</code>s.</p> <p>First you need two arrays like this:</p> <pre><code>var ajaxPages=['ajax1.html','ajax2.html','ajax3.html','ajax4.html'];//File Names var divPages=['div1','div2','div3','div4'];//Div ids in order </code></pre> <p>For the AJAX part you should use something like:</p> <pre><code>var getHtml = function(filename,divid){ $.post('html/'+filename, function(data) { //The first argument is your file location //Second one is the callback, data is the string retrieved $('#'+divid).html(data); }); } $.each(ajaxPages,function(index,value){ getHtml(value,divPages[index]); }); </code></pre> <p>That should do it... Do tell me if you require further explanation.</p> <p>EDIT:</p> <pre><code>var ajaxPages=['ajax1.html','ajax2.html','ajax3.html','ajax4.html']; var divId="yourdivid"; var textArray=new Array(); var currentImg=0; var getHtml = function(filename){ $.post('html/'+filename, function(data) { textArray.push(data);//Save data inside the array textArray }); } $.each(ajaxPages,function(index,value){ getHtml(value,divPages[index]); }); </code></pre> <p>Then your goNext() method:</p> <pre><code>function goNext() { var next = $('#gallery&gt;img.current').next(); if(next.length == 0){ next = $('#gallery&gt;img:first'); currentImg=0; }else{ currentImg++; } $('#gallery&gt;img').removeClass('current'); next.addClass('current'); loadImage(next.attr('src')); $('#'+divId).html(textArray[currentImg]);//Adds text to div based on current picture } </code></pre> <p>That should be working fine!</p>
    singulars
    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.
 

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