Update ajax.php

Some comments to the code and cleanup