xmlHttpRequest on Vista Home

I have utilized xmlhttp on many occasions to power ajax enabled projects and have never had a problem with it until now. The following javascript code is debugged and runs flawlessly in IE7, but does not work when installed as a gadget. Is there something in here that gadgets do not support but IE7 does

function GetXmlHttpObject(handler)
{
var objXmlHttp=null;
var strName="Microsoft.XMLHTTP";
try
{
objXmlHttp=new ActiveXObject(strName);
objXmlHttp.onreadystatechange=handler;
return objXmlHttp;
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled");
return;
}

}

function showDisplay()
{
var url="http://www.ourwebsite.com/phpscript.php variable=one";
xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("gadgetContent").innerHTML=xmlHttp.responseText;
}
}

When the function showDisplay() is called, the response from ourwebsite.com should be placed within the gadgetContent element. Any help is appreciated!



Answer this question

xmlHttpRequest on Vista Home

  • Fabriciom

    I just tested the following code (in my gadget):

    function submitForm()
    {
    var xhr=null;

    try
    {
    xhr = new XMLHttpRequest();
    }
    catch(e)
    {
    }

    xhr.onreadystatechange = function()
    {
    content.innerHTML = "Wait server...";
    if(xhr.readyState == 4)
    {
    if(xhr.status == 200)
    {
    content.innerHTML = "Received:" + xhr.responseText;
    }
    else
    {
    content.innerHTML = xhr.status + " " + xhr.statusText;
    }
    }
    };

    xhr.open("GET", "http://www.thomaslinder.at/beta.txt", true);
    xhr.send(null);
    }

    ...

    <body onload="onLoad()" id="mainBody" onclick="submitForm()">

    Works like a charm ....


  • watch is

    Business 32bit
  • R.S.N

    The gadget.xml file is very simple and I'm doubtful that anything in there would have caused it. In fact, after testing the gadget on several different computers I have come to the conclusion that something on our network may be causing the problem. The gadget works fine on my friends computer outside of this network, but it does not work on the 3 vista powered computers on this network. Is there anything along these lines that you think could cause it
  • magikalpnoi

    Could you please post your gadget.xml file


  • DOSrelic

    I've actually already tried that with the same results.  My best guess as to what is causing it would be a 'permission denied' error due to a cross domain scripts.

     After doing an error catch, this is the problem.  'Access is denied.'  Any thoughts


  • N. Farr

    To be honest: I don't know of anything, than a blocking firewall (but why would it block that traffic) ... Could it be you're sitting behind some proxy


  • Blueforce

    So, we have narrowed it down to a problem with both Vista Home basic and premium. Both of these versions of Vista do not allow gadgets to perform xmlHttpRequest.open without throwing an 'Access is denied' error.

    Thomas, thank you for your help thus far. Does anyone have any information regarding this issue


  • DoubleDangerBat

     Jough wrote:

    We have in fact narrowed it down to a Vista Home issue after testing the gadget on many computers (both in and outside the network) running various versions of Vista on various internet connections. All computers had the default IE7 security settings.

    ...

    If you have access to a Vista Home (basic or premium), I invite you to create your own simple gadget similar to that of Thomas Li which includes an xmlHttpRequest. I would really like to know the result.

    I doubt this issue is specific to certain versions of Vista. Prior to replying I tested both Home Premium and Ultimate and neither had the problem.

    I don't have access to a Home Basic key so I can't test that, but the fact I can't reproduce the problem on Home Premium, plus the fact a few Ultimate's are seeing the same problem tells me it's a config issue.

    If an IE reset doesn't fix it (which will reset the local security policy), common sense tells me it has to either be a GPO policy (which can be ruled out quite quickly), router/proxy/firewall issues or a software conflict.

    I know it's a pain, but install Virtual PC 2007 and install a fresh copy of Vista Home Premium on it. If it doesn't work you've ruled out software conflicts - which leaves you with an issue at the network layer.

  • ronwest99

    What version of vista are you using   We may have narrowed it down to a Home version problem.  It seems to work on Ultimate.
  • Michael Hansen

    We have in fact narrowed it down to a Vista Home issue after testing the gadget on many computers (both in and outside the network) running various versions of Vista on various internet connections. All computers had the default IE7 security settings.

    "3. Try trusting the domain your pulling data from."

    I thought this may be the issue as I had found it mentioned several places online. Unfortunately, this will only solve problems related to gadgets working on live.com - and not on the sidebar. I tried it anyway, to no avail.

    If you have access to a Vista Home (basic or premium), I invite you to create your own simple gadget similar to that of Thomas Li which includes an xmlHttpRequest. I would really like to know the result.


  • Larry Smith

    See, now I run that exact same script in a gadget on my computer (using both your thomaslinder.at domain and my own) and I get an 'Access is denied' error during the xmlhttprequest.open
  • FelipeLopez

    You might consider using the "real" XMLHttpRequest Object instead of an ActiveX Object.

    http://en.wikipedia.org/wiki/XMLHttpRequest


  • jortiz

    You mention it's on a Network. Do you have an IE security policy in place through a GPO Either XMLHttpRequest or ActiveX may be disabled.  Sounds unlikely as it works in IE.

    If this isn't the case, try the following within IE:

    1. In Internet Options, within the Security section on the Advanced tab. Ensure "Enable native XMLHTTP support" is ticked.

    2. Try resetting all the security zones to default - or even reset IE completely (Reset button on the Advanced tab).

    3. Try trusting the domain your pulling data from.

    4. See if the PC's that are failing have different Proxy configs to the ones that work.

    From your description, it sounds like a security zone issue.

  • kc ppm

    I'm having a very similar problem. At both work and home I have Vista Ultimate. At home, the gadget works fine in both IE and the sidebar. However, at work the gadget generates the access denied error in both IE and the sidebar. An XP computer at work runs the gadget in IE perfectly fine.

    This may be because the Vista Ultimate work computer is not on my company's domain. But if I access the page it's trying to download with XMLHttp in IE, it loads perfectly fine.

    Any thoughts


  • xmlHttpRequest on Vista Home