Correct method for a Block calling PHP with AJAX

Correct method for a Block calling PHP with AJAX

by Miles Fletcher -
Number of replies: 2

Hello,

I haven't been about to find any documentation on the correct way to do this. I'm working on a Moodle Block which I would like, when a user interacts with the page by right-clicking certain elements, makes a Moodle database query and displays the results in a GUI by the element,

The way I would instinctively do this is to add a new PHP file to the block directory which accepts POST data arguments and prints out result information, then call this using .ajax in Jquery.

Is this the correct way to go about this type of interactivity or are there specific ways to do this for blocks that I should be following?

Average of ratings: -