kembalikan ob_start

// ON a server side context before returning some data to AJAX client:
<?php 
function getData() {
  ob_start();
  ?>

  <div class="some-class">
	Some HTML 
    <?php echo "Some custom data"; ?>
  </div>

  <?php 
  return ob_get_clean(); // Returns all collected data
  // Much better than using a concatenanted variable 
}
gtamborero