by Alexandre Ribeiro.
So i'm trying to use ajax call by the documentation so my js function is:
var promises = ajax.call([{
methodname: 'block_cdtexpflowchart_get_workflow_steps',
args: { workflowid: workflowID }
}]);
promises[0].done(function (response) {
console.log('------------response------------');
console.log(response);
}).fail(function(ex){
console.log('------------ ERROR ------------');
console.log(ex);
});
i've created a services.php file in db folder of my plugin:
$functions = array(
'block_cdtexpflowchart_get_workflow_steps' => array(//web service function name
'classname' => 'block_cdtexpflowchart_external', //class containing the external function
'methodname' => 'get_workflow_steps', //external function name
'description' => 'return a list of steps for the given workflow id', //human readable description of the web service function
'type' => 'read', //database rights of the web service function (read, write)
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE) // Optional, only available for Moodle 3.1 onwards. List of built-in services (by shortname) where the function will be included. Services created manually via the Moodle interface are not supported.
),
);
$services = array('Moodle mobile web service' => array('functions' => array('block_cdtexpflowchart_get_workflow_steps')));
and i've created too a function declaration, and _parameters and _return in my external.php file in the root of my plugin
public static function get_workflow_steps($workflowid)
{
global $CFG, $DB;
return $DB->get_records_sql('SELECT stepstable.id, stepstable.workflowid, stepstable.stepno,'
. 'stepstable.name, stepstable.instructions, stepstable.onactivescript, stepstable.oncompletescript '
. 'FROM block_workflow_steps stepstable '
. 'WHERE stepstable.workflowid = ?', array($workflowid));
}
so, when i test this, i get the error :
Error: missing response(…)