add waiting for ajax request is complete