• mehrwash

    (@mehrwash)


    I want to show the recent comments on the homepage and created a function for that, added the hooks and all.
    It works perfectly that is it gets me the comments, but when I call the same function via AJAX- for Loading on windows scroll, it gets messed up.
    The function itself output the List of comments , with gd star rating etc. The function does not return anything but outputs directly from the code using <div>s and echos.

    I am new to all this so thank you for your help

    My Windows Scroll Code:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    $(document).scroll(function(){
       // if ($(window).scrollTop() + $(window).height() == $(document).height())
    	if ($(window).scrollTop() == $(document).height() - $(window).height())  {
       		LoadonButton();
    
        }
    });
    
    function LoadonButton (){
    	jQuery.ajax({
      	url: 'http://dino-dev.com/foodie/wp-admin/admin-ajax.php',
      	data: {
      		action: 'HomeComments'
      		},
      	success: function(data, textStatus, XMLHttpRequest){  
    
      		jQuery("#post-content").append(data);
      		},
      	error: function(MLHttpRequest, textStatus, errorThrown){
      		alert(errorThrown);
     }
      });  }

The topic ‘Ajax function’ is closed to new replies.