sync.php, fighting with AJAX