bravo14 Posted October 20, 2013 Share Posted October 20, 2013 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 More sharing options...
kicken Posted October 20, 2013 Share Posted October 20, 2013 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. Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454641 Share on other sites More sharing options...
bravo14 Posted October 20, 2013 Author Share Posted October 20, 2013 Thabks for the reply am I right in saying after looking that on has replaced live? Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454653 Share on other sites More sharing options...
alpine Posted October 20, 2013 Share Posted October 20, 2013 Yes, use on instead of live $('.load_more').on("click",function(){ } Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454668 Share on other sites More sharing options...
Irate Posted October 20, 2013 Share Posted October 20, 2013 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). Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454673 Share on other sites More sharing options...
kicken Posted October 20, 2013 Share Posted October 20, 2013 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. Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454674 Share on other sites More sharing options...
bravo14 Posted October 20, 2013 Author Share Posted October 20, 2013 Thanks guys, changed it to .on and it works a treat Link to comment https://forums.phpfreaks.com/topic/283120-live-is-not-a-function/#findComment-1454678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.