Jump to content

live is not a function


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
https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/
Share on other sites

You're probably not using the proper version of jQuery. If you check the documentation you can see that the live method was removed in 1.9, so you'd either need to use an older version or update your code to be compatible with the newer versions.

  On 10/20/2013 at 7:34 PM, Irate said:

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.