Jump to content

Noob with javascript - Expected ) error


Nuv

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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());
});

});

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.