Closed mishal closed 7 years ago
I don't want to modify the original Event object. And actually, I don't think this is necessary at all. You could simply prevent the default action for tdi:ajax:beforeLinkClick
and send the request yourself:
$(document).on('tdi:ajax:beforeLinkClick', 'a', function(e) {
e.preventDefault();
TDI.Ajax.send(evt.target, {
beforeStart : function(xhr, settings, ajaxOptions) {
xhr.setRequestHeader('X-Foobar', 'yes');
return true; // make the request
}
});
});
Ok, thanks.
This could be part of the docs as a simple howto.
I moved the docs into the repository. So you can suggest changes yourself.
I've already updated the docs with this example snippet: https://github.com/twinstone/tdi/blob/master/docs/web-page-integration/web-page-integration-js.md
Thanks! Good job :)
I have to setup custom http header before sending ajax requests. This can be simply implemented by:
I did not included any test for this - checked the tests sources but could not find suitable place.