diff --git a/ajax.php b/ajax.php --- a/ajax.php +++ b/ajax.php @@ -67,14 +67,15 @@ function slate_permutate_json_success(ar if (isset($_REQUEST['school_registration_html'])) { - if (!empty($_REQUEST['school'])) - $school = school_load($_REQUEST['school']); + /* + * Since we're just an AJAX callback, ask school_load_guess() not + * to update $_SESSION with the school the user is using... And + * make sure that the frontend actually tells us what school the + * user is using ;-). + */ + $school = school_load_guess(FALSE); if (empty($school)) - { - $school = school_load_guess(); - if (empty($school)) - slate_permutate_json_error('Unable to load any school.'); - } + slate_permutate_json_error('Unable to load any school.'); $page = page::page_create(''); diff --git a/scripts/displayTables.js b/scripts/displayTables.js --- a/scripts/displayTables.js +++ b/scripts/displayTables.js @@ -49,7 +49,8 @@ function show_box_change() * The jQuery object which should be populated with an error message * or the result of loading. * \param data - * The data to send as a request. + * The data to send as a request. The school and semester keys shall + * automatically be set. * \param handler * A function with the signature handler(target, data) which is called upon * a successful response. There is a default handler which uses @@ -70,6 +71,11 @@ function slate_permutate_load(target, da target.html(data.html); } + if (!data.school) + data.school = slate_permutate_school; + if (!data.semester) + data.semester = slate_permutate_semester; + if (jQuery.type(error_handler) == 'undefined') error_handler = function(target, status_text, data) {