add BeforeAjax callback

This is useful to set a request header when fetching ajax resources.