Получить данные MigX через ajax
        Добрый день!
Нужна помощь с получением TV параметра при загрузке через Ajax
Вывожу данные ресурса через Ajax следующим методом.
     
    
    
                                                                                
            Нужна помощь с получением TV параметра при загрузке через Ajax
Вывожу данные ресурса через Ajax следующим методом.
<?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || empty($_REQUEST['action'])) {exit();}
$action = $_REQUEST['action'];
define('MODX_API_MODE', true);
require_once dirname(dirname(__FILE__)).'/index.php';
$modx->getService('error','error.modError');
$modx->getRequest();
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('FILE');
$modx->error->message = null;
$output = '';
switch ($action) {
    case 'getContent':
        $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
        if (empty($id)) {
            exit();
        };
        $object = $modx->getObject('modResource',$id);
	      $output = array();
        $output['content'] = $object->get('content');
      	$output['pagetitle'] = $object->get('pagetitle');
      	$output = json_encode($output);
        $maxIterations= (integer) $modx->getOption('parser_max_iterations', null, 10);
        $modx->getParser()->processElementTags('', $output, false, false, '[[', ']]', array(), $maxIterations);
        $modx->getParser()->processElementTags('', $output, true, true, '[[', ']]', array(), $maxIterations);
}
@session_write_close();
exit($output);JS$(document).on('click','a.read-more',function(e){
      e.preventDefault();
      var id = $(this).data('id') || 0;
      $("#content").load("/assets/ajax.php",{action:"getContent",id:id}, function(response){
        if (response) {
          var data = eval("(" + response + ")");
          $('#content').html(data.content);
          $('#modal-title').html(data.pagetitle);
          $("#mymodal").modal('show');
        }
      });
    });С выводом обычных TV проблем нет. но не могу разобраться как получить данные из MigX?Комментарии: 3
$maxIterations= (integer) $modx->getOption('parser_max_iterations', null, 10);
        $modx->getParser()->processElementTags('', $output, false, false, '[[', ']]', array(), $maxIterations);
        $modx->getParser()->processElementTags('', $output, true, true, '[[', ']]', array(), $maxIterations);А зачем так сложно? Почему не$modx->parseChunk();А migx хранится в json, получить его можно как любую другую твшку$res = $modx->getObject('modResource', 8);
$migx = $res->getTVValue('test');
print_r(json_decode($migx,1));            
                Вместо "MIGX_TV" укажи свой TV.
                    <?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || empty($_REQUEST['action'])) {exit();}
$action = $_REQUEST['action'];
/* @global $modx*/
define('MODX_API_MODE', true);
require_once dirname(dirname(__FILE__)).'/index.php';
$modx->getService('error','error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_FATAL);
$output = array();
switch ($action) {
    case 'getContent':
        $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
        if (empty($id)) {
            exit();
        };
        $object = $modx->getObject('modResource',$id);
        $output['content'] = $object->get('content');
        $output['pagetitle'] = $object->get('pagetitle');
        $output['MIGX_TV'] = json_encode($object->getTVValue('MIGX_TV'),true);
        $output = json_encode($output);
        break;
    default:
        $output = array("st"=>"error");
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($output);            
                Вообще перестало что-либо выводить. 
Выводит все вот так.
                    Выводит все вот так.
"pagetitle\":\"\\u041a\\u043e\\u0440\\u043e\\u0431\\u043a\\u0430-\\u0441\\u044eА MigX выводит вот так[{\\\\\\\"MIGX_id\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"image\\\\\\\":\\\\\\\"l3d5rthre4.jpg\\\\\\\",\\\\\\\"deleted\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"published\\\\\\\":Возможно нужно править JS =(            
                            Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.