We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49371
    • 6 Posts
    Hi there smiley

    I have my custom Doodle tables created with the part I of the tutorial "Developing an extra in MODX".

    Now i would like to add ajax queries possibilities in the front-end.

    As my english is not very good, I'm not sure what the Part II of the tutorial is about.

    Is the Part II useful to add ajax features to the front-end ?

    Or is it only useful in order to build custom manager pages for Doodle ?

    :)

    POST SCRIPTUM :

    don't hesitate to share, if you have good links or tutorials about using ajax with modx ( INSERT, UPDATE, DELETE...)

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Part II is for creating a CMP. If you want to access the data in the front-end with AJAX, you already have all that you need.

      In MODX, AJAX is generally done with a resource with no template and nothing but the snippet that fetches the data. The resource's URL is the URL for the AJAX query. The snippet fetches the data, then processes it to return whatever you want for the AJAX output. You can fetch data and convert it to a JSON array to return, or you can have MODX generate formatted HTML output with getChunk, and return fully formatted HTML to load into a specified DOM container.

      The trick is to keep the two things separate: the AJAX request to the URL and the processing of the returned content is the job of Javascript. Receiving the request and doing whatever is need to generate the content to return is the job of your snippet. You just need to know what parameters to send to the snippet, and what format you need to get back.
        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
        • 49371
        • 6 Posts
        thank you Sottwell for the explanations smiley