First off I must apologise, I know questions similar to what I'm about to ask have been asked before, but none of the answers or suggestions given in those questions are working for me.
Heres the story:
I have written a function that sends an ajax request to the server which in turn runs a php script which performs a query on a database and returns an html element, specifically it returns: <a href="mypage.php">Click here</a>. This is my code:
$('#txtHint').hide();
function showReviews(str) {
$.ajax({
xhr: function() {
if ($.browser.msie)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
return new XMLHttpRequest();
}
},
url: "dropsearch.php",
cache: false,
type: "post",
data: "q=" + str,
dataType: "html",
success: function(data) {
$('#txtHint').append(data);
$('#txtHint').show();
window.alert(data);
}
});
}
Now, this works perfectly fine in normal browsers, the a tag is returned in the response header and appended to the txtHint div. However, with Internet Explorer, the response header isn't returning anything. I've even used firebug and fiddler to see exactly what the headers are sending and returning, and for some reason although IE is sending the correct header and receiving one back, it's not receiving the content. The window.alert() call just displays an empty alert box in IE.
I've been reading that IE has problems with cache when it comes to ajax calls; however, ensuring the request isn't cahced doesn't work.
Does any body have any idea why this is happening? It's been driving me absolutely nuts!
Any advice would be much appreciated.
Cheers
xhrproperty in your call to$.ajax? That shouldn't be needed. Theajaxfunction figures out the proper request object for you.