Concrete5 Load Area with Ajax

Permalink
I am trying to pull area of a page with Ajax. In JS I have on click I pass href to PHP; in PHP(located in tools):
<?php  defined('C5_EXECUTE') or die("Access Denied.");
  $path = ($_POST['path']);
  $page = Page::getByPath($path);
  $a = new Area('Main');
  $ret = $a->display($page);
  echo json_encode($ret);
?>

If I make:

echo json_encode($page);

I receive the page so everything working, But when I try to receive an Area I get this error:

concrete\elements\block_area_header_view.php on line 5


In this File I found this

$c = Page::getCurrentPage();
$areaStyle = $c->getAreaCustomStyleRule($a);

So as I understand $c is null that why I have this error how can I fix this??

sergio11ofpp
 
JohntheFish replied on at Permalink Reply
JohntheFish
There are a couple of ways to do this with marketplace blocks:

a) Global Areas addon and Blocks by AJAX addon

b) Universal Content Puller addon and Blocks By AJAX addon