Nuv Posted March 5, 2011 Share Posted March 5, 2011 Hi guys, I was trying pagination without reloading the page from the blog http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html However when i run it on my editor there is an error and i can't figure it out. Javascript code - $(document).ready(function() { //Display Loading Image function Display_Load() { $("#loading").fadeIn(900,0); $("#loading").html("<img src="bigLoader.gif" />"); } //Hide Loading Image function Hide_Load() { $("#loading").fadeOut('slow'); }; //Default Starting Page Results $("#pagination li:first") .css({'color' : '#FF0084'}).css({'border' : 'none'}); Display_Load(); $("#content").load("index.php?page=1", Hide_Load()); //Pagination Click $("#pagination li").click(function(){ Display_Load(); //CSS Styles $("#pagination li") .css({'border' : 'solid #dddddd 1px'}) .css({'color' : '#0063DC'}); $(this) .css({'color' : '#FF0084'}) .css({'border' : 'none'}); //Loading Data var pageNum = this.id; $("#content").load("index.php?page=" + pageNum, Hide_Load()); }); }); Error - Line : 7 Error - Expected ')' Continue running script anyway ? Line 7 is $("#loading").html("<img src="bigLoader.gif" />"); Can someone please help me to work it Quote Link to comment Share on other sites More sharing options...
.josh Posted March 5, 2011 Share Posted March 5, 2011 You aren't using quotes properly. use single quotes for the outer quotes, double for the inner, or visa versa. Or escape the inner ones. Quote Link to comment Share on other sites More sharing options...
Nuv Posted March 5, 2011 Author Share Posted March 5, 2011 Thankyou.Now there are no errors.However its not working. This is a part of index.php where i am inserting pagination How should i insert pagination data there ? How should i make it work ? If you need complete index.php i can post that too. <div class="post_content"> <p> <?php // NEED TO INSERT PAGINATION DATA HERE - pagination.php retrieves the data from the database ?> </p> </div> <div class="clr"></div> </div> <p class="pages"><small>Page <?php echo $page; ?> of <?php echo $pages; ?></small> <?php for($i=1; $i<=$pages; $i++) { if($i == $page){ echo '<span>'.$page.'</span>'; } else{ echo ' <a href="index.php?page='.$i.'">'.$i.'</a>' ; } } ?> </p> Pagination.php -- This retrieves the data from the database <?php $per_page = 10; $page = 1; if(isset($_GET['page'])) { $page=$_GET['page']; } $start = ($page-1)*$per_page; $sql = "select * from state order by id limit $start,$per_page"; $dat = mysql_query($sql); while($row = mysql_fetch_array($dat)) { $state=$row['state']; ?> <p><span> • </span> <a href="#"><strong><?php echo $state; ?></strong></a> <?php } ?> Final jquery_pagination.js $(document).ready(function() { //Display Loading Image function Display_Load() { $("#loading").fadeIn(900,0); $("#loading").html('<img src="bigLoader.gif" />'); } //Hide Loading Image function Hide_Load() { $("#loading").fadeOut('slow'); }; //Default Starting Page Results $("#pagination li:first") .css({'color' : '#FF0084'}).css({'border' : 'none'}); Display_Load(); $("#content").load("pagination.php?page=1", Hide_Load()); //Pagination Click $("#pagination li").click(function(){ Display_Load(); //CSS Styles $("#pagination li") .css({'border' : 'solid #dddddd 1px'}) .css({'color' : '#0063DC'}); $(this) .css({'color' : '#FF0084'}) .css({'border' : 'none'}); //Loading Data var pageNum = this.id; $("#content").load("pagination.php?page=" + pageNum, Hide_Load()); }); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.