Good day to all!

There is a question: how can you dynamically load content? For example, the msProducts snippet is called, in which, for example, elements 10 are loaded, an event on the scroller should work at the bottom or on the button load another 10 elements. The fact that this is using the ajax script will be understandable. Excites another - as in the request to avoid direct access to the database?

For example, an external file is called:

$.ajax({ url: 'load.php', method: 'GET', data: {"num" : num}, beforeSend: function() { inProcess = true; } }) 

Then in the file load.php there is a call to the database:

 $num = $_GET['num']; $query = mysql_query("SELECT * FROM `news` ORDER BY `date` DESC LIMIT {$num}, 10"); $news = array(); while ($row = mysql_fetch_array($query)) { $news[] = $row; } 

Under the conditions that we are working not with pure php, but modx, I wanted to ask how such problems are solved in this CMS? Thank you all for your attention to my question.

    1 answer 1

    Bezumkin has AjaxSnippet . And here is a good article on working with Ajax in MODX (see the demo).

    • Yes, this is exactly what you need). Thank! - IntegralAL