Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

Ajax request always returns null

Author Message
Squeegy



Joined: 28 Aug 2007
Posts: 2
Location: Santa Rosa, CA

Posted: Tue Aug 28, 2007 - 5:13 pm    Post subject: Ajax request always returns null Reply with quote

I have a basic Ajax request coming from my widget that wont ever return anything besides null.

Here's the code in question:

Code:

var req = new XMLHttpRequest();
url = "http://www.yahoo.com/";
req.open("GET", url, false);
req.send(null);
response = req.responseText;
   
alert('WIDGET DEBUG: ' + response)


I replaced yahoo with my data source, just to be sure there is nothing wrong with my data source.

When this runs as a widget, the console output always says "WIDGET DEBUG: null". It's like it doesn't even try to get the webpage.

It works great in Safari if I set this up to fetch a local page, and host on my local server (ie. http://localhost:3000/) as long as the javascript and the document being fetched are on the same domain. But Safari will not send ajax requests to other domains, and the dashboard seems to have the same rules.

But dashboard Ajax ALWAYS has to access other domains. So what the dickens am I doing wrong? Every example I have read says its easy, and disassembling other widgets always yields similar results.

I even tried to use prototype.js and "new Ajax.Request()", it's call back never fired on the dashboard, even though it worked in Safari (on the same domain).

I'm sure it's something simple, I'm just too stupid to get. Any pointers?
View user's profile Send private message Send e-mail Visit poster's website Widgets
Squeegy



Joined: 28 Aug 2007
Posts: 2
Location: Santa Rosa, CA

Posted: Tue Aug 28, 2007 - 6:38 pm    Post subject: Reply with quote

After slamming my face on my desk few many, many hours this issue finally came down to a missing property in my Info.plist

Code:
<key>AllowNetworkAccess</key>
<true/>


How embarrassing...
View user's profile Send private message Send e-mail Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group