To Do List Project: Part 3

Today I replaced part of the update code with a basic AJAX call to derive the same information I was getting from JavaScript. The communication itself is straightforward. Here’s the updated version of the JavaScript, which is currently embedded in the UpdateToDo.php file.

Here’s the (mindlessly simple) UpdateStartTime.php file:

If the last part of the last line is uncommented then it returns the ToDoID that was sent with the AJAX request. This test was a precursor to adding a MySQL call to create a new time slice record in the database, associated with the current To Do item for the current user.

Two lines are commented out in the embedded JavaScript above. If they are uncommented then when the user clicks on the Start button the button is first replaced with the text “error encountered” and then with the date-time string returned by the AJAX. I’m still mentally getting a feel for this. The callback function is only “called” once, right? Well, no. It must be getting called on every change of state through the whole data exchange process, and as I recall from reading there are a number of such state changes. If I modify the new function as shown below, so it includes the count of the number of times the callback function is invoked, it ends up displaying a value of four, meaning that four state changes occur.

Now the trick is to understand what they all are and the best way to differentiate between a delayed reaction and a failed transfer so the process looks smooth and graceful.

Eventually I’ll have to address time zone issues if all timestamps are generated server side.

This entry was posted in Software and tagged , , . Bookmark the permalink.

Leave a Reply