Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38287

[META] Convert AJAX scripts not using AJAX_SCRIPT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.3.4, 2.7.3, 2.8.1, 2.9
    • JavaScript
    • MOODLE_23_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE

      I've noticed a couple of scripts recently which aim to render both HTML, and JSON in one script rather than splitting out the HTML to one script, and JSON to another.
      So far I think that they've all (I think there's a whole two) taken the 'ajax' parameter. If it's set then they return json instead of html.

      However, because AJAX_SCRIPT has to be defined before config.php is included and the page is setup, any exceptions which may be thrown would not be wrapped in JSON but use the standard HTML output.

      There are two possible solutions that I can see:

      • split out all scripts into two; or
      • set AJAX_SCRIPT to true in lib/setup.php if a truthful AJAX parameter was sent.

      The second option feels much dirtier - what if someone calls their field json instead of ajax for example, or what if ajax was the name of a variable on the page for some other reason?

      If we go for the option of splitting them out, then I think that we should standardise on a naming scheme for such things to indicate the purpose.

      Mahara have standardised on a scheme I personally quite like:
      Standard script: foo.php
      AJAX script: foo.ajax.php

            Unassigned Unassigned
            dobedobedoh Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.