function misha_loadmore_ajax_handler() {
$args = json_decode ( stripslashes ( $_POST[ 'query' ] ), true );
$args[ 'paged' ] = $_POST[ 'page' ] + 1;
$args[ 'post_status' ] = 'publish';
query_posts ( $args );
if( have_posts () ) :while ( have_posts () ): the_post ();
?>
<div class="griditem">
<a class="producturl" href="<?php the_permalink (); ?>">
<div class="productimagewrapper">
<img class="lazyload" data-src="<?php the_post_thumbnail_url (); ?>" />
</div>
<div class="productinfo">
<h2 class="productname"><?php the_title (); ?></h2>
<span class="productprice">$<?php echo esc_html ( get_post_meta ( get_the_ID (), 'price', true ) ); ?>.00</span>
</div>
</a>
</div>
<?php
endwhile;
endif;
die;
}
or you can use ob_start ()
function misha_loadmore_ajax_handler() {
$args = json_decode ( stripslashes ( $_POST[ 'query' ] ), true );
$args[ 'paged' ] = $_POST[ 'page' ] + 1;
$args[ 'post_status' ] = 'publish';
$new_html = array();
query_posts ( $args );
if( have_posts () ) :while ( have_posts () ): the_post ();
ob_start ();
?>
<div class="griditem">
<a class="producturl" href="<?php the_permalink (); ?>">
<div class="productimagewrapper">
<img class="lazyload" data-src="<?php the_post_thumbnail_url (); ?>" />
</div>
<div class="productinfo">
<h2 class="productname"><?php the_title (); ?></h2>
<span class="productprice">$<?php echo esc_html ( get_post_meta ( get_the_ID (), 'price', true ) ); ?>.00</span>
</div>
</a>
</div>
<?php
echo ob_get_clean ();
endwhile;
endif;
die;
}