Pulled AJAX JS into separate function