将javascript变量发布到PHP并在Javascript方法中返回结果

I have a javascript function that runs each time a slider is changed in a slideshow checking for 2 conditions:

Is this the last slide in the slideshow and is the activeIndex less than the total records of the database table where all slides come from.

If so, fetch 3 more records from the database starting at the same number as the javascript activeIndex and append the results to the slider.

Can I do some sort of post and return results into the value of mySwiper.appendSlide method?

    ...
    keyboardControl: true,
    onSlideNextStart: function(){          
    if ((mySwiper.isEnd == true) && (mySwiper.activeIndex < <?php echo $totalCount; ?>)) {
    mySwiper.appendSlide('***return HTML here from post***');
      }         
     } 

You need to use ajax:

keyboardControl: true,
onSlideNextStart: function(){          
  if ((mySwiper.isEnd == true) && (mySwiper.activeIndex < <?php echo $totalCount; ?>)) {
    $.post( 'php_that_return_sliders.php', { activeIndex :mySwiper.activeIndex }).done(function( data ) {
         mySwiper.appendSlide( data );
    });        
  }         
} 

Create a php_that_return_sliders.php that returns sliders html based on activeIndex sent in $_POST.