Answer the question
In order to leave comments, you need to log in
How to make ajax loading from a block in the same document?
The task is to make an Ajax menu on one of the sections of the site under the control of MODX Revo. Unfortunately, I'm not very familiar with ajax. At the moment everything works like this
$(".menu-item").click(function(){
var id = $(this).attr('id');
$.ajax({
type: "POST",
url: "ajaxitems.html",
data: ({findres:id}),
success: function(content){
$(".ordersItems").html(content);
}
});
});
<?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
$data = $_POST;
$params = array(
'parents' => $data['findres'],
'limit' => $limit,
'tpl' => $tpl,
'includeTVs' => $includeTVs,
'hideContainers' => $hideContainers,
'sortby' => $sortby
);
$output = $modx->runSnippet('pdoResources', $params);
return $output;
}
Answer the question
In order to leave comments, you need to log in
Send a request to the same page, and instead of $(".ordersItems").html(content); output $(".ordersItems").html($(content).filter("#result_block")); where result_block is the id of the element containing the information you are interested in.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question