I have a select element that does a post using jQuery on a change event, I was trying to post it to a snippet and get the results back, however it seems that if the snippet is called directly from javascript there will be no notion of the ($modx
) object and i can't access the DB using PDO, my code is as follows:
$(document).ready(function() {
$('#camplist').change(function() {
$.post('core/components/evoprograms/snippets/register-camp.php?action=getCamp&id=' + $(this).val(), function(data) {
$("camp-details").show();
$('.result').html(data);
});
});
});
What's the right approach to do it?