    // When the page loads.
    $(function() {
        $('#new-task').bind('submit', onNewTaskFormSubmit);

        datePicker = $("#task-date").datepicker({
            firstDay: 0
        });

        loadTaskLists();
    });

    /**
    * Load the available task lists.
    */
    function loadTaskLists() {  
        $.get("backend.php?method=getCachedTaskLists", function(data) {
            showTaskLists(data);
            $.get("backend.php?method=getTaskLists", function(data) {
                showTaskListsPreservingSelection(data);
            });
        });  
    }

    /**
    * Show the returned task lists in the dropdown box.
    * @param {Array.<Object>} taskLists The task lists to show.
    */
    function showTaskLists(taskLists) {
        var select = $('#tasklist');
        select.empty();
        taskLists.forEach(function(taskList) {
            var option = $('<option>')
            .attr('value', taskList.id)
            .text(taskList.title);
            select.append(option);
        });
    }

    /**
    * Show the returned task lists in the dropdown box.
    * The original selection in the box is preserved.
    * @param {Array.<Object>} taskLists The task lists to show.
    */
    function showTaskListsPreservingSelection(taskLists) {
        var selectedValue = $('#tasklist').val();

        showTaskLists(taskLists);

        if (selectedValue) {
            $('#tasklist option[value=' + selectedValue + ']').prop('selected', true);
        }
    }

    /**
    * A callback function that runs when the new task form is submitted.
    */
    function onNewTaskFormSubmit() {
        var taskListId = $('#tasklist').val();
        var titleTextBox = $('#task-title');
        var noteTextBox = $('#task-note');
        var title = titleTextBox.val();
        var note = noteTextBox.val();
        var dateObj = $("#task-date").datepicker( "getDate" );
        var date = dateObj ? dateObj.getFullYear() + '-' + (dateObj.getMonth()+1) + '-' + dateObj.getDate() : "";
        var dateArgument;
        if (date) {
            dateArgument = "&taskDate=" + date;
        }

        $.get("backend.php?method=addTask&taskListId=" + encodeURIComponent(taskListId) +
            "&title=" + encodeURIComponent(title) + "&note=" + encodeURIComponent(note) +
            dateArgument,
            function() {
                $("#outer").html("<p>Task added.</p>");
            }
        );
        return false;
    }

    /**
    * Logs an error message and shows an alert to the user.
    */
    function showError(error) {
        console.log(error);
        window.alert('An error has occurred, please try again.');
    }
@@ -2032,16 +2032,21 @@
 Argument
+ = %22%22
 ;%0A      

Fix bug: "undefined" was added to URL when task had no date