Writting own AJAX class

Writting own AJAX class

by Pete Fox -
Number of replies: 1

Hi guys,

class MyAjax {

public function __construct() {

/*session_name('MoodleSession');
session_start();

echo session_id();*/

}

public function test() {

define('AJAX_SCRIPT', true);

require_once('config.php');

//require_login();

echo $_SESSION['USER']->id;



}

}
 
Can someone please provide me some information about how to write a moodle ajax controller.
I need to get the login data and do some database stuff. When i uncomment req_login() i get a error message :(
 
Thank you.
Average of ratings: -
In reply to Pete Fox

Re: Writting own AJAX class

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What parts of Moodle do you know that already do Ajax? (Hint, try rating this forum post). How does that existing code work?