Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
130
rated 0 times [  136] [ 6]  / answers: 1 / hits: 97021  / 14 Years ago, wed, february 23, 2011, 12:00:00

I have an iframe using the jQuery 1.4.2 script. The same iframe is injected into both http and https sites. The jQuery script is included in the main HTML file as a relative path (e.g., /scripts/jquery-1.4.2.min.js).



When an AJAX call is made, Internet Explorer denies access. The AJAX is calling on another subdomain, but it's using the right protocol. All other browsers work but Internet Explorer gives the following error:




SCRIPT5: Access is denied.

jquery-1.4.2.min.js, line 127 character 344




I heard this error is from cross-domain AJAX calls. But why is IE the only one giving me crap? Is there an IE solution?



Also, this is my AJAX:



 $.ajax({
url: thisURL,
dataType: json,
data: {cmd : 'getMessage', uurl: urlVar, t: Math.random()},
success: function(ret){
callback(ret)
}
});

More From » jquery

 Answers
18

IE requires you to use XDomainRequest instead of XHR for cross site, you can try something like...



if ($.browser.msie && window.XDomainRequest) {
// Use Microsoft XDR
var xdr = new XDomainRequest();
xdr.open(get, url);
xdr.onload = function() {
// XDomainRequest doesn't provide responseXml, so if you need it:
var dom = new ActiveXObject(Microsoft.XMLDOM);
dom.async = false;
dom.loadXML(xdr.responseText);
};
xdr.send();
} else {
// your ajax request here
$$.ajax({
url: thisURL,
dataType: json,
data: {cmd : 'getMessage', uurl: urlVar, t: Math.random()},
success: function(ret){
callback(ret)
}
});

}


Reference



http://forum.jquery.com/topic/cross-domain-ajax-and-ie



not sure whether it fits your scenario



xdr = new XDomainRequest(); 
xdr.onload=function()
{
alert(xdr.responseText);
}
xdr.open(GET, thisUrl); //thisURl ->your cross domain request URL
//pass your data here
xdr.send([data]);


you can find some more guidance here


[#93621] Monday, February 21, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;