Refactor ajax search code to use .getscript