[backend] wait_for_ajax rather than sleeping for an arbitrary point of time