I would assume you want to put this before for insert the data into the database, so withing the write part of the switch before the SQL query.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.