I have an ajax call that is working fine on Chrome, FF and Safari but always fail on IE ("success but no data"). I've checked server logs and the right response always triggers but still IE shows empty response and doesn't catch the right 302 http status code. I've tried many combinations and found that when using contentType: "text/html; charset=utf-8" IE does get the response but the problem is that $_POST array is empty since sending POST should be contentType: "application/x-www-form-urlencoded; charset=utf-8"
This is my javascript:
function someFunc() {
$.ajax({
cache: false,
async: false,
type: 'POST',
dataType: 'html',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
//contentType: "text/html; charset=utf-8",
url: myProtocol + myHost + "/mypage.php",
data: {action: "someAction"},
success: function( data ) {
if (data == ""){
alert("success but no data");
return;
}
// do something...
return;
},
error: function( data ) {
if (data.status == "302"){
// do something...
return;
} else {
// do something...
return;
}
}
});
return;
}
this is my PHP response (mypage.php):
$loginUrl = "someUrl";
header("HTTP/1.1 302 Found");
header("Content-Type: text/html; charset=utf-8");
Header("Content-Length: " . mb_strlen($loginUrl, "8bit"));
header("Connection: close", true);
echo $loginUrl;
Only on IE 7-9 I end up with "success but no data" on other browsers works perfect. any idea? somebody?
Thanks!