IE8 AJAX GET setRequestHeaders not working unless params provided in URL
Posted
by bobthabuilda
on Stack Overflow
See other posts from Stack Overflow
or by bobthabuilda
Published on 2010-04-17T06:12:07Z
Indexed on
2010/04/17
6:13 UTC
Read the original article
Hit count: 457
I'm trying to create an AJAX request in IE8.
var xhr = new ActiveXObject( 'Msxml2.XMLHTTP' );
xhr.open( 'GET', '/ajax/' );
// Required header for Django to detect AJAX request
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
xhr.onreadystatechange = function() {
if ( this.readyState == 4 ) console.log(this.responseText);
}
xhr.send( null );
This works perfectly fine in Firefox, Chrome, Safari. In IE8 however, all of my AJAX test requests work EXCEPT for ones where I'm performing GETs without any query string params (such as the one above). POSTs work without question, and GET requests only work whenever I include query strings in the URL, like this:
xhr.open( 'GET', '/ajax/?foo=bar' )
I'm also 110% positive that my server code is handling these requests appropriately, so, this stumps me completely.
Does anyone have any clue as to what might be causing this?
© Stack Overflow or respective owner