Forum Moderators: open

Message Too Old, No Replies

Access Denied in Explorer

         

supermanjace

3:31 am on Oct 21, 2008 (gmt 0)

10+ Year Member



I am testing out a page a I built that utilizes an AJAX function. When I run this site on Firefox it works perfectly, but when I try to do that same thing in IE I a warning to allow the Active X control which I do allow. But when I click on an anchor that fires an AJX command I get an error that tells me access is denied at line 55, character 3 (which is my http.open function) code:0. I cannot figure it out for the life of me...

Any thoughts?

daveVk

4:46 am on Oct 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the domain of the url in this statement the same as the page within ? If not that will be the issue. Also there is a native ( non Active X ) version of HttpRequist on later versions of IE you should test for.

supermanjace

5:09 am on Oct 21, 2008 (gmt 0)

10+ Year Member



Dave,

You are my hero for getting back to me. The url of the xml doc is within the same folder as the html doc that's calling it. It's a relative link that is just the following :
http.open('get', 'beerdescriptions.xml', true)

Is that the issue you think? Any thoughts on a solution?

Also, can you help me with the native test for later IE? here's my full script:

<script type="text/javascript">
function fix_external_links() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "external") {
anchor.target = "_blank";
}
}
}
window.onload = fix_external_links;
function createRequestObject() {
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
return xmlHttp;
}
var http = createRequestObject();
function sndReq() {
var that = this; // The link that triggered this event
// The callback function for the http request
http.open('get', 'beerdescriptions.xml', true)
http.send(null);
http.onreadystatechange = function () {
var found = 0

if (http.readyState == 4) {
// that refers to the link
var test = that.innerHTML

var response = http.responseXML.documentElement
var set = response.getElementsByTagName("SET")

beerslicestart = test.lastIndexOf('<');
beersliceend = test.lastIndexOf('">') + 2;
beerslice = test.substring(beersliceend,beerslicestart);
brewersliceend = test.lastIndexOf('</span> ');
brewerslicestart = test.lastIndexOf('nd">') + 4;
brewerslice = test.substring(brewersliceend,brewerslicestart) + " ";
fullname = brewerslice.concat(beerslice);

for (i=0;i<set.length;i++){

testset = set[i].getElementsByTagName("COMPARISON")
comparison = testset[0].firstChild.data

if (fullname == comparison){


var beer = set[i].getElementsByTagName("BEER")
var brewer = set[i].getElementsByTagName("BREWER")
var description = set[i].getElementsByTagName("DESCRIPTION")
var image = set[i].getElementsByTagName("IMAGE")
var abv = set[i].getElementsByTagName("ABV")
var location = set[i].getElementsByTagName("LOCATION")
var website = set[i].getElementsByTagName("WEBSITE")
var style = set[i].getElementsByTagName("STYLE")


document.getElementById("craftbeer").innerHTML= "<a href="+website[0].firstChild.data+" class='brewerlink' rel='external'>"+brewer[0].firstChild.data+"</a> <br />"
document.getElementById("beerinfo").innerHTML= description[0].firstChild.data
document.getElementById("beername").innerHTML= beer[0].firstChild.data
document.getElementById("beerimage").innerHTML= "<img src="+image[0].firstChild.data+" class='beerimage' alt="+beer[0].firstChild.data+" />"
document.getElementById("source").innerHTML= ""
document.getElementById("style").innerHTML= "Style: "+style[0].firstChild.data
document.getElementById("abv").innerHTML= "ABV: "+abv[0].firstChild.data
document.getElementById("location").innerHTML= "Point of Origin: "+location[0].firstChild.data

found = 1

}

}


}
}

}
// When the window loads, attach the event handlers to the links
// but only if AJAX is working
if (http) {
window.onload = function () {
var i, els = document.getElementsByTagName('a');
// Loop through all the links
for (i = els.length; i > 0; i--) {
// Attach the onclick handler to each link
els[i-1].onclick = sndReq;
}
}
}
</script>

daveVk

6:38 am on Oct 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cant fault code, it should use native for IE 7+ as per Firefox etc. So assume you as using IE 6 or earlier win2K ? Double check all active setting.

ps sticky me url of page to see if same prob here.

[edited by: daveVk at 6:56 am (utc) on Oct. 21, 2008]

supermanjace

5:06 pm on Oct 21, 2008 (gmt 0)

10+ Year Member



I feel like a dope (perhaps because I am one), but I hasn't the slightest idear what the devil you mean by native for IE 7+. As for my page, I'll sticky it to you... What seems to happen is that on click of the anchors it actually opens the page that I have href="#" which seems odd. and of course that doesn't fill the inner html of the divs...