Answer the question
In order to leave comments, you need to log in
Cross-domain AJAX Vkontakte?
Hello.
There was a problem with adapting a simple iframe of the Vkontakte game for IE8+, namely with ajax requests.
The application is loaded via IFRAME from the site sub.domain.ru/game.php. AJAX requests are sent from a script (JavaScript) using jQuery to sub.domain.ru/api.php. In Chrome/FF/Safari/Opera everything works without problems. In IE8/9, Ajax requests simply don't work or get blocked (no response).
Code for sending requests:
$.ajax({
type: "POST",
async: isAsync,
url: URL,
data: params,
success: function(answer) {
....
}
});
header('Content-Type: text/html; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET');
$.support.cors = true;
Answer the question
In order to leave comments, you need to log in
Probably because older IEs use XDomainRequest .
There is also written about the solution .
The problem turned out to be completely different and it is related to cookies... Cookies are set for the user during "authorization" and for all ajax requests of the user, the server checks these cookies to understand that this is the "correct" user:
setcookie("uid", $uid, time()+3600*24, '/');
.....
For some reason, cookies are not set in IE - probably this is due to IFRAMEs... The PHP script sets cookies from the sub.domain.ru/game.php domain, and then they are sent along with the request to sub.domain.ru/api.php where they are checked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question