finish base ajax function code and change window in code to global