[jQuery] jQuery not setting X-Requested-With XMLHttpRequest
I'm using jQuery 1.2.6, and I can't seem to get jQuery to set the X-
Requested-With when it makes AJAX calls. I saw somewhere that this
may have to do with cross-site issues if the host is specified in the
URL. I've tried skirting around that by just passing a relative URL,
but with no success. I'm wondering what I might be doing wrong, or if
someone can point me in the right direction. Here's what my jQuery
code looks like:
$.ajax({
type: "POST",
url: '/votes/43',
dataType: "html",
data: "method=delete",
success: function(data) {
$(this).parents('div.vote_box').after(data).remove();
}
});
I've tried it also by adding a beforeSend, of:
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
},
I've inspected the request headers with Firebug and with a separate
HTTP tracing tool, and the X-Requested-With header is never present.
The host, when I'm debugging like this is "http://localhost:3000", or
I've also tried with "http://localhost" (i.e. just running on 80).
I've tried this in both Firefox 3 and Safari.