Jump to content

live is not a function


bravo14
Go to solution Solved by bravo14,

Recommended Posts

Hi Guys

 

I have the following page

 

 

<script src="js/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function() {



$('.load_more').live("click",function() {


var last_msg_id = $(this).attr("id");



if(last_msg_id!='end'){
    
  $.ajax({
type: "POST",
url: "facebook_style_ajax_more.php",
data: "lastmsg="+ last_msg_id,
beforeSend:  function() {
$('a.load_more').append('<img src="facebook_style_loader.gif" />');
 
},
success: function(html){
    $(".facebook_style").remove();
$("ol#updates").append(html);


}
});
 
}


 
 
 



return false;


});
});

</script>

 

This ajax is called when a user clicks a link similar to facebook's Show Older Posts code is below

 

 

<ol class="row" id="updates">
    <?php
$query ="select * from `tbl_news` ORDER BY `news_date` desc LIMIT 9";
$result = mysql_query($query);
while($row=mysql_fetch_assoc($result))
{
$msg_id=$row['id'];
$message=$row['headline'];
?>
    <li> <?php echo $message; ?> </li>
    <?php } ?>
  </ol>

 
 
  <div class="facebook_style" id="facebook_style">
  <a id="<?php echo $msg_id; ?>" href="#" class="load_more" >Show Older Posts <img src="img/arrow.png" /> </a>
  </div>

 

When I am clicking on the link I am getting the following error showing in Firebug

 

TypeError: $(...).live is not a function
 

$('.load_more').live("click",function() {

 

Where am I goign wrong, I have used th tutorial and source code from the followign page

 

http://youhack.me/2010/05/14/an-alternative-to-pagination-facebook-and-twitter-style/

 

Link to comment
Share on other sites

You can also use bind, too, which accepts any amount of event binders as space-separated list, "mouseenter mouseleave" for example (which would equal hover, anyway).

.on accepts space-separated event list as well. .bind is also not recommended (use .on instead) but has not been removed as of yet.

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.