Ajax function moved to js file.