Simple Widget, NETWORK_ERR problem

Discussion in 'Mac Programming' started by thebouv, Feb 26, 2008.

  1. thebouv macrumors newbie

    Feb 26, 2008
    I downloaded Apple's very simple Hello World example.

    I added some very simple XMLHttpRequest code.

    It fails.

    And Console tells me this:

    2/26/08 9:23:38 AM [0x0-0x7007][149] 2008-02-26 09:23:38.678 DashboardClient[524:10b] ( file:///Users/anthony/Library/Widgets/Hello%20World.wdgt/HelloWorld.html: NETWORK_ERR: XMLHttpRequest Exception 101 (line: 18) 
    And I can't find any help on that through Google.

    My Info.plist (so you can see I'm using AllowNetworkAccess):

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
    	<string>Hello World</string>
    And now the HelloWorld.html file:

    body {
    margin: 0;
    background-image: url("Default.png");
    <script language='JavaScript'>
    function UpdateData () {
     var request = new XMLHttpRequest();"GET", "",false);
     myInfo = request.responseText;
     document.getElementById("myDiv").innerHTML = myInfo;
    <body onload="UpdateData();">
    		<div id='myDiv'>Hello, World!</div>
    Now, this works perfectly fine in Safari. But as a widget, it keeps "Hello, World!" and throws the error above in Console.

    Any insight on this would be greatly appreciated.
  2. thebouv thread starter macrumors newbie

    Feb 26, 2008
    No one had any info on this, but I did find out what was going on through a few hours of messing around.

    Apparently, the first time you install a widget, your Info.plist better be perfect, because any changes aren't read in afterwards.

    The first time I made my widget above, it just printed out a message and I had no idea about needing AllowNetworkAccess. Then I added AllowNetworkAccess to Info.plist and the simple Ajax code -- and there started the troubles mentioned in my first post.

    Even when I removed the widget from the Dashboard AND removed the wdgt file from my Library/Widgets folder and reinstalled it, no go. But if I made a copy and changed CFBundleIdentifier/etc the same code worked. Putting those same changes into the first widget's Info.plist still failed.

    If there is a way to clear that cached Info.plist, I'd like to know, because that is a hell of an annoying thing to deal with during devel testing.
  3. jhulten macrumors newbie

    Jun 6, 2008

    Can you provide step-by-step of what you did? I have the same issue and cannot replicate it.
  4. Fongchowpei macrumors newbie

    Jun 20, 2008
    I had the same exact issue, bugged me for so long... spent a long time debugging my code in vain...

    jhulten, the only thing i found that could fix it was to rename the widget. Apparently, it looks like a user-specific issue though, but I couldn't find any plist or cache that would refresh the info.plist. Even renaming the widget back to the original name went back to the old info.plist. If anyone figures it out, that would be great to know.

Share This Page