Reputation: 212
I need add different headers to html page in js, but I don't know how. In php that was easy, but now I write in Java and on html page i have only js to use. Any idea ?
Upvotes: 1
Views: 131
Reputation:
jQuery(document).ajaxSend(function(event, xhr, settings) {
...
// xhr is an XMLHttpRequest object
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
I think your problem can be solved by the above code.
Upvotes: 0
Reputation: 212
I need something like include() in php. I need add different html heads depending on url.
Upvotes: 0
Reputation: 6000
use this:
xhr.setRequestHeader('header', 'value');
butI think the easiest way to accomplish it is to use querystring instead of HTTP headers.
Upvotes: 1