Cross domain AJAX (YQL) - Navigate between consequent data pages of the variable query changed by click

Cross domain AJAX (YQL) - Navigate between consequent data pages of the variable query changed by click

I have some divs:
  1.  <div id="id1"><h3>A</h3><h4>X</h4></div>
  2.  <div id="id2"><h3>B</h3><h4>Y</h4></div>
  3.  <div id="id3"><h3>C</h3><h4>Z</h4></div>

And use xdomainajax plugin ( YQL powered)  -
 to  load external pages.


I added  the following function :
When i click on div it search for <h3> contents in  the external dictionary and loads it to the "#cont"

  1. $("div")  .click(function(){
  2.  var filter = $('h3',this).text();
  3.  $('#cont') .load ('http://jisho.org/words?jap=*'+filter+'*');
  4.   
  5. });
In current form it loads the desired results - but only the first page  .

I would like to add function that:
* when div is clicked search its <h3> content in the dictionary and load it to "#cont"
* have navigation feature that load consequent dictionary pages of the found word (triggered by prev/next buttons)
* when clicking on another div it change the search query and use the same buttons to navigate through new result pages

for example :
  1. http://jisho.org/words?jap=*%E6%B0%B4*&page=2
  2. http://jisho.org/words?jap=*%E6%B0%B4*&page=3
  3. http://jisho.org/words?jap=*%E6%B0%B4*&page=4
  4. http://jisho.org/words?jap=*%E6%B0%B4*&page=5

etc

i  failed  using these two functions :

  1. $("div")  .click(function(){
  2. var filter = $('h3',this).text();
  3. $ ('#buffer') .empty();
  4. $('#buffer') .append   ('http://jisho.org/words?jap=*'+filter+'*');
  5. });


  1. var filterone = $('#buffer') .contents () .clone ();
  2.      var curIndex = 0;
  3. function fun(index) {
  4.       curIndex = parseInt(index);
  5.  $('#cont').load (filterone+"&page="+index);
  6.  
  7. }

and then  navigation by
  1.  
  2. function forw() {
  3.       fun(curIndex + 1);
  4. };
  5. function back() {
  6.       fun(curIndex - 1);
  7. };
Your help would be appreciated.