Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 402 and 403]

Library functions to facilitate the use of ajax JavaScript in Moodle.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 82 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 functions


Functions that are not part of a class:

user_preference_allow_ajax_update($name, $paramtype)   X-Ref
You need to call this function if you wish to use the set_user_preference method in javascript_static.php, to white-list the
preference you want to update from JavaScript, and to specify the type of cleaning you expect to be done on values.

param: string          $name      the name of the user_perference we should allow to be updated by remote calls.
param: integer         $paramtype one of the PARAM_{TYPE} constants, user to clean submitted values before set_user_preference is called.
return: null

ajax_capture_output()   X-Ref
Starts capturing output whilst processing an AJAX request.

This should be used in combination with ajax_check_captured_output to
report any captured output to the user.

return: Boolean Returns true on success or false on failure.

ajax_check_captured_output()   X-Ref
Check captured output for content. If the site has a debug level of
debugdeveloper set, and the content is non-empty, then throw a coding
exception which can be captured by the Y.IO request and displayed to the
user.

return: Any output that was captured.