Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Load More Articles Mysql Jquery

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
K0smiC
Smarty Rookie


Joined: 23 Sep 2013
Posts: 5

PostPosted: Tue Mar 04, 2014 7:36 pm    Post subject: Load More Articles Mysql Jquery Reply with quote

Hi,

I have a problem.

I find myself facing a problem in creating a button to dynamically load the items in your home the script works but the data-rel prettyphoto is not interpreted.
I'll post the codes:

Code:
{literal}<script type="text/javascript">


   var track_click = 0; //track user click on "load more" button, righ now it is 0 click
   
   {/literal}var total_pages = {$TOT_PAGES};{literal}
   $('#results').load("modules/home/fetch_pages.php", {'page':track_click}, function() {track_click++;}); //initial data to load

   $(".load_more").click(function (e) { //user clicks on button
   
      $(this).hide(); //hide load more button on click
      $('.animation_image').show(); //show loading image

      if(track_click <= total_pages) //make sure user clicks are still less than total pages
      {
         //post page number and load returned data into result element
         $.post('modules/home/fetch_pages.php',{'page': track_click}, function(data) {
         
            $(".load_more").show(); //bring back load more button
            
            $("#results").append(data); //append data received from server
            
            //scroll page to button element
            $("html, body").animate({scrollTop: $("#load_more_button").offset().top}, 500);
            
            //hide loading image
            $('.animation_image').hide(); //hide loading image once data is received
   
            track_click++; //user click increment on load button
         
         }).fail(function(xhr, ajaxOptions, thrownError) {
            alert(thrownError); //alert any HTTP error
            $(".load_more").show(); //bring back load more button
            $('.animation_image').hide(); //hide loading image once data is received
         });
         
         
         if(track_click >= total_pages-1)
         {
            //reached end of the page yet? disable load button
            $(".load_more").attr("disabled", "disabled");
         }
       }
       
      });

</script>
{/literal}


fetch_pages.php code:

Code:
include("config.inc.php"); //include config file
//sanitize post value
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);

//throw HTTP error if page number is not valid
if(!is_numeric($page_number)){
   header('HTTP/1.1 500 Invalid page number!');
   exit();
}

//get current starting point of records
$position = ($page_number * $item_per_page);

//Limit our results within a specified range.
$results = mysqli_query($connecDB,"SELECT * FROM news_db WHERE status=1 UNION SELECT * FROM blogs_db WHERE status=1 ORDER BY date_wr DESC LIMIT $position , $item_per_page");

//output results from database
$c=0;
while($row = mysqli_fetch_array($results))
{

   echo ' <li class="span6">
                       
                                   <div class="view_title_port">                   
                                        <a href="blog_news-dettaglio.html"><h4>Title news</h4></a>
                                        <span class="port_cat"><p> facilis democritum ea quoest ei illum consulatu a expetenda suavitate ipsum dolor sit </p> </span>
                                    <span class="clear"></span>
                                    <a href="blog_news-dettaglio.html"><div class="port_read_more box_news">read more... <i class="icon_port_more"></i></div></a>
                                  </div>
                                   
                                   <div class="view">
                                    <div class="h_port_image">
                                    <a href="images/news/1.jpg" title="" data-rel="prettyPhoto[portfolio]" class="view_image_news">                
                                        <img src="images/news/1.jpg" alt="">               
                                        <div class="link_overlay_news icon-search"></div>
                                     </a>
                                    </div>
                                  </div>
                                  <span class="clear"></span>
                                 
                        </li> ';
}


I think it's due to a problem related to append jquery.

someone can help me?
Back to top
View user's profile Send private message
K0smiC
Smarty Rookie


Joined: 23 Sep 2013
Posts: 5

PostPosted: Fri Apr 04, 2014 10:21 am    Post subject: Reply with quote

up Sad
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Apr 04, 2014 1:37 pm    Post subject: Reply with quote

That is a lot of code to sift through and not have a working implementation to see. Use the Chrome debugger and step through the javascript, make sure there are no errors.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP