Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thebouv

macrumors newbie
Original poster
Feb 26, 2008
2
0
I downloaded Apple's very simple Hello World example.

I added some very simple XMLHttpRequest code.

It fails.

And Console tells me this:

Code:
2/26/08 9:23:38 AM [0x0-0x7007].com.apple.dock[149] 2008-02-26 09:23:38.678 DashboardClient[524:10b] (com.apple.widget.helloworld) 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):

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDisplayName</key>
	<string>Hello World</string>
	<key>CFBundleIdentifier</key>
	<string>com.apple.widget.helloworld</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>CloseBoxInsetX</key>
	<integer>16</integer>
	<key>CloseBoxInsetY</key>
	<integer>14</integer>
	<key>MainHTML</key>
	<string>HelloWorld.html</string>
        <key>AllowNetworkAccess</key>
        <true/>
</dict>
</plist>

And now the HelloWorld.html file:

Code:
<html>

<head>

<style>
body {
margin: 0;
background-image: url("Default.png");
}


</style>

<script language='JavaScript'>
function UpdateData () {
 var request = new XMLHttpRequest();
 request.open("GET", "http://www.whatismyip.com",false);
 request.send();
 myInfo = request.responseText;

 document.getElementById("myDiv").innerHTML = myInfo;
}

</script>

</head>

<body onload="UpdateData();">
		
		<div id='myDiv'>Hello, World!</div>

</body>

</html>

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.
 

thebouv

macrumors newbie
Original poster
Feb 26, 2008
2
0
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.
 

jhulten

macrumors newbie
Jun 6, 2008
1
0
Instructions?

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.

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

Fongchowpei

macrumors newbie
Jun 20, 2008
1
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.