Added ajax code to the actual script