We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27733
    • 99 Posts
    I’m developing a module in evo that uses some ajax calls to grab data and place it into one of my module’s forms (when a particular checkbox is ticked). The ajax fetches a front-end document which, in turn, calls a snippet (which passes a ref to the $modx obj into a processing class) to get and send back new data to my form. I’m finding that certain parser functions do not work in this context (such as getChunk and parseChunk). I’m hazarding a guess that this may have something to do with losing the current mgr validated session when making the ajax call? Any advice on maintaining access to all properties when passing data in and out this way?
      ------
      Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
    • Hmm. I’ve used this method for all of my AJAX features for quite a while and never had a problem with it. Those functions shouldn’t have any dependence on your session, besides which an AJAX request is no different from any other HTTP request, so the session shouldn’t be lost. I’ll do some checking and get back to you. This actually would be a good topic for an article on MODx and AJAX.
        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
      • Actually I’ve already written an article on using extJS and AJAX four years ago (which is why I had forgotten about it), and that should make it pretty clear that the AJAX processor resource gets the same SESSION as any other page request would. The application described in the articles is still working just fine, and by its nature depends on the SESSION being correctly set, as it fetched data from the database to fill the extJS data grid depending on what user is logged in.

        So this is a different problem. I’m still looking into it.
          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
          • 27733
          • 99 Posts
          Susan,

          Thank you for investigating! I’m familiar with your article and, if I remember correctly, the example is based on a one-page interface, right? ... Where different content is loaded to the same page via ajax calls ...? Just FYI, as you consider my question, my module has several pages, requiring me to carry a ref to $modx throughout.

          As I looked into getChunk in the parser class, I noticed it looks for it via a cache property rather than directly querying the db for it. I’m guessing there are a number of methods that will look for data from various caches in a similar manner. Could it be that access to certain/all caches is tied to the session? If so, could passing the session id through one of the ajax request variables be the answer?

          Cheers,
          Jim
            ------
            Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.