User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,628 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,904 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1211 | Replies: 9
Reply
Join Date: Mar 2007
Posts: 42
Reputation: toadzky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
toadzky toadzky is offline Offline
Light Poster

Question IE AJAX issue

  #1  
Feb 7th, 2008
I am trying to insert/hide a table in my page using AJAX.

Works perfectly in Firefox. IE 7 gives me "Error: Access is denied" for the following line:
xmlReq.open("GET", url, true);

Any ideas why?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Help Re: IE AJAX issue

  #2  
Feb 7th, 2008
There is insufficient information here to help you out. I recently created an AJAX code that would dynamically create a table and populate its table data. Could that be what you are trying to accomplish.
Reply With Quote  
Join Date: Mar 2007
Posts: 42
Reputation: toadzky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
toadzky toadzky is offline Offline
Light Poster

Re: IE AJAX issue

  #3  
Feb 8th, 2008
i have the table save in HTML format in a separate file.

i'm using an xmlHttpRequest object in firefox to retrieve it and doing this:

div.innerHTML = xmlReq.responseText;

like i said, works in Firefox but not IE.

and yes, in the IE version im using the ActiveX object instead of the standard.
Last edited by toadzky : Feb 8th, 2008 at 1:02 am.
Reply With Quote  
Join Date: Mar 2006
Posts: 36
Reputation: sree22_happy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
sree22_happy's Avatar
sree22_happy sree22_happy is online now Online
Light Poster

Re: IE AJAX issue

  #4  
Feb 8th, 2008
Did u get the responseText in IE ?
Can u alert the responseText in IE
Reply With Quote  
Join Date: Mar 2007
Posts: 42
Reputation: toadzky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
toadzky toadzky is offline Offline
Light Poster

Re: IE AJAX issue

  #5  
Feb 8th, 2008
It doesn't ever get that far. It returns the "Access denied error" on:

xmlReq.open("GET", url, true);
Reply With Quote  
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Re: IE AJAX issue

  #6  
Feb 8th, 2008
chances are your AJAX script is breaking down before you even get to the response text. what I would recommand is to test the script by inserting a series of alerts up to the point where you are expecting certain result. For example, when I test my AJAX code, I checked to see if my object is created by alerting the object. If it is created, then I test the readystate to see if the value is equal to 4 and so on.

can you post your entire AJAX code in here so we can look at it?
Reply With Quote  
Join Date: Mar 2007
Posts: 42
Reputation: toadzky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
toadzky toadzky is offline Offline
Light Poster

Re: IE AJAX issue

  #7  
Feb 8th, 2008
//Quick check for AJAX functionality. Copied from w3schools.com
function MakeXMLReq()
{
  var xmlHttp = null;

  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    // Internet Explorer 6+
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      //For IE 5.5 Users
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }

  return xmlHttp;
}

function getTable(info)
{
  var tableDiv = document.getElementById("externalTable");
  var xmlReq = MakeXMLReq();

  xmlReq.onreadystatechange = function()
  {
    if (xmlReq.state = 4)
    {
      try
      {
        tableDiv.innerHTML = xmlReq.responseText;
        tableDiv.innerHTML += "<br /> <a href = \"#top\" onclick = \"hideDiv()\" class = \"internal text-center\">Hide Table</a>";
        tableDiv.style.display = "inline";
      }
      catch (ex)
      {
        alert("Error: Unable to display AJAX retrieved table.");
        return;
      }
    }
  }
  
  var url = info + "_table.html";
  xmlReq.open("GET", url, true);
  xmlReq.send(null);
}
Reply With Quote  
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Re: IE AJAX issue

  #8  
Feb 8th, 2008
One problem that I noticed right away is that your getTable() method is evaluating the the state of xmlReq within the if statement but you are assigning it a value of 4 rather than evaluating it to 4. So make this correction and try to run the script again.
 if(xmlReq.state == 4)
Second, I am not sure that you can use the word state instead of readystate, so you might want to experiment to see which on works.

While you are working on the aforementioned fix, I'll try to see what else is wrong with the code.
Reply With Quote  
Join Date: Mar 2007
Posts: 42
Reputation: toadzky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
toadzky toadzky is offline Offline
Light Poster

Re: IE AJAX issue

  #9  
Feb 8th, 2008
I think I found the problem. Seems that I have to be running the page as an HTTP page instead of a local page. Firefox doesn't care but it looks like IE doesn't let local pages access HTTP services.

I hate IE...
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: IE AJAX issue

  #10  
Feb 9th, 2008
> It doesn't ever get that far. It returns the "Access denied error" on:

Are you trying to make cross domain calls? What kind of URL are you using in your call anyways? Does it belong to your domain?
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC