igor-alexandrov/wiselinks — pull request #94 by phlegx (2014-12-18 23:24:29+00:00)
Title: Add xhr object to callbacks. Add additional header X-Wiselinks-Target.

# Add xhr object to callbacks

To handle headers in Wiselinks callbacks (javascript events) I have added xhr in callbacks for page:fail, page:redirected, page:done. The xhr in the callbacks can be very useful.

**Example**

```javascript
$(document).off('page:done').on('page:done', function(event, $target, status, url, data, xhr) {
message = xhr.getResponseHeader('X-Flash-Message');
type = xhr.getResponseHeader('X-Flash-Message-Type');
});
```

**Javascript Events**

1. **page:done** ($target, status, url, data, **xhr**)
2. **page:fail** ($target, status, url, error, code, **xhr**)
3. **page:redirected** ($target, render, url, **xhr**)

# Add additional header X-Wiselinks-Target

This can be useful in the controller.