Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 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.