We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    If you need just one field at a time you can run for example getResourceField inside your snippet with
    return $modx->runSnippet('getResourceField',$scriptProperties)
    ;

    or if you need to get more fields you can do the same with getResources.
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Just use the URL to the resource as the target of your AJAX call:
      $.get( "myAJAXresource.html", ...


      Personally, I much prefer using load() http://api.jquery.com/load/
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 45227
        • 12 Posts
        Quote from: sottwell at Oct 21, 2013, 07:45 PM
        Just use the URL to the resource as the target of your AJAX call:
        $.get( "myAJAXresource.html", ...


        Personally, I much prefer using load() http://api.jquery.com/load/

        Thanks Bruno and Susan, u guys were much help...I have finally gotten the thing.
        For the template variables that were not getting resolved I used placeholders instead then passed an array containing the TV name/value as array elements.

        //handle the template variables
        $someresource = $modx->getObject('modResource',$someresourceId);
        $resourceArray = $someresource ->toArray();
        
        $tvArray = array();
        $templateVars = &$someresource->getMany('TemplateVars');
        foreach($templateVars as $templateVar)
            $tvArray[$templateVar->get('name')] = $templateVar->get('value');
        
        $pageArray = array_merge($resourceArray,$tvArray );  //gets all template tags for the page: TVs, Chunks, Snippets
        
        return $modx->getChunk($tpl,$pageArray );   //the chunk must contain placeholders that values on the pageArray will replace
        


        There may be a better solution but other than some possible performance issues this is perfect for my use case. after I deal with this deadline I intend to come back to thhis if I can get a better way.