We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m playing around with AJAX and otherwise just refreshing a small portion of the page (expanding my addition calculator to a shoutbox; very little difference, input two string arguments, output one string result, the only difference being database access in the processing).

    It seems to me a bit much to have to include config.inc.php and document.parser.class.inc.php and create a new instance of the DocumentParser class in the php file the AJAX script is calling, when all you want is to grab a few rows off the database and return them so AJAX can load them into a <div> or even an iframe in a sidebar.

    But as far as I can tell, that’s the only way to be able to use the modx API in an external file called by AJAX, or the "action" of, say, a calendar options form.

    By using a special template, I suppose you could actually make the action of a form behave as if you were going to refresh the whole page (i.e. having [~123~] as the action), but only inserting the result into your div or iframe or whatever. But as far as I can tell, AJAX wouldn’t work like that; it has to be fed directly from your function call. In either case, that’s like driving your SUV half a block to get a can of Pepsi.

    So I’m making up a very light include file with some file management and database abstracton functions that can be called by complex snippets that don’t want to call the whole modx engine. Sort of like a bicycle you can keep on a rack on your SUV for those quick Pepsi runs...

    In case anybody else finds the idea interesting. Or has a better idea.
      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
      • 32963
      • 1,732 Posts

      There’s a DBAPI to be included with TP3. It does eveything that you’ve requested from ezSQL library.
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 4673
        • 577 Posts
        Is this library a home brew? Or is it something 3rd party?
        also, can we get a look at it a little early?
        And one more Q -- does it cache query results?

        Thanks smiley
          Tangent-Warrior smiley
        • For now, I’m using the ez-sql library; including ../../../../manager/includes/config.inc.php so I can use the site database configuration. I am still looking for a nice little file access class; don’t really need file access at the moment, just thought it would be useful to have in my "arsenal". I’m building up quite a nice library of javascript utilities; the Apple development site has some great tutorials with scripts and libraries free for use.
            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
            • 32963
            • 1,732 Posts
            Quote from: Carsten at Jun 25, 2005, 10:00 AM

            Is this library a home brew?? Or is it something 3rd party?
            also, can we get a look at it a little early?
            And one more Q -- does it cache query results?

            Thanks smiley

            Well this one will be integrated with the modx library and can also be used as a standalone library. I’ll try and see what can be done about getting you an early preview. No promises though.

            At this present point in time it does not cache results. This feature could be implemented in later versions.





              xWisdom
              www.xwisdomhtml.com
              The fear of the Lord is the beginning of wisdom:
              MODx Co-Founder - Create and do more with less.
              • 4673
              • 577 Posts
              Thanks!

              Would appreciate it!

              I’m just wondering why something was built in-office compared to using a 3rd party solution?
                Tangent-Warrior smiley
                • 32963
                • 1,732 Posts
                Quote from: Carsten at Jun 26, 2005, 03:31 PM

                Thanks!

                Would appreciate it!

                I’m just wondering why something was built in-office compared to using a 3rd party solution?

                Well it’s really a combination of two other extenal APIs plus a little internal stuff as well. If you look at what it can you you will never be the same smiley

                for example:
                -------------
                How many lines will it take you to select some records from a database and display the result inside a grid? Or how many lines will it take to convert your recordset to xml?

                With the DBAPI I could do it in one or two lines.


                  xWisdom
                  www.xwisdomhtml.com
                  The fear of the Lord is the beginning of wisdom:
                  MODx Co-Founder - Create and do more with less.
                • Oh, did I forget to mention the ez-results library that goes with ez-sql? http://www.jvmultimedia.com/home/docs/ezr/ez_results_help.htm
                    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
                    • 4673
                    • 577 Posts
                    heheh, sottwell got there before i did. Yes, I did see it smiley
                      Tangent-Warrior smiley
                      • 4673
                      • 577 Posts
                      ugh, no edit button.

                      anyway, so ... you gonna show some stuff smiley smiley smiley

                      I’m dieing to see at least an example smiley
                        Tangent-Warrior smiley