move ajax request to layout