B
B
boicko2014-11-21 13:06:31
CORS
boicko, 2014-11-21 13:06:31

How to make CORS work in IE8/9?

Actually, why does not work, it is clear.
The question is the following.
For IE, I found the jquery.iecors.js plugin, connected it as described in the doc.
They write that it is enough to connect and everything, then everything will go.
Indeed, through $.ajax it is possible to send a request and receive a response, but for some reason POST data is not sent.
That is, with such a request:
$.ajax({
type: "POST",
url: " http://ххх/test.php ",
data: ({test: "aaa"}),
crossDomain: true,
success: function(resp){
alert(resp);
}
});
emptiness comes.
On the server in the file test.php I just write echo $_POST['test'];
Well, of course, before that, all the headers.
In all browsers I get the expected response, i.e. "ahh" and IE8/9 - nothing.
Can't help, what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
boicko, 2014-11-27
@boicko

I found this solution for a cross-domain ajax request:
$(function(){
// request using jQuery
$.ajax({
url: ' http://ххх.com/test.php ',
success: function(data){
alert (data);
},
error: function(data){
alert(data);
},
type: "GET",
dataType: "text"
});
// similar request
var client = new XMLHttpRequest();
client.open( "GET", " http://xxx.com/test.php ")
client.onreadystatechange = function() {}
client.send();
});
test.php:
<?php
header('Access-Control-Allow-Origin:');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/html; charset=utf-8;');
echo 'hello world';
?>
In all browsers I get 'hello world', in IE9 [object Object].
Why is it so? I really, really need help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question