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 Design

XMLHttpRequest Problem

Author Message
HotPantsOn



Joined: 24 Feb 2006
Posts: 5

Posted: Fri Feb 24, 2006 - 11:02 pm    Post subject: XMLHttpRequest Problem Reply with quote

Im sure you are all sick of hearing about AJAX issues .. well here's one that I am totally stumped on and would appreciate any help.

I am attempting to retrieve content from a php page (NOT an XML page) and am using responseText for this. My code works fine if I open it in Safari, however in Dashboard the responseText is null! I went a step further and downloaded Widgetarium to help debug this. Running this through Widgetarium gives me the correct results, just like in Safari! Only in Dashboard is this not working. The following is my .js code:

Code:
function createRequestObject(){
   var request_o;
   var browser = navigator.appName;
   if(browser == "Microsoft Internet Explorer"){
      request_o = new ActiveXObject("Microsoft.XMLHTTP");
   }else{
      request_o = new XMLHttpRequest();
   }
   return request_o;
}

var http = createRequestObject();
url = "http://www.condo-southflorida.com/ajax.php?param=39";
http.open("GET", url ,false);
http.send(null);
response = http.responseText;
document.getElementById('content').innerHTML = "This is the response: " + response;


This next snippet is my simple HTML code:
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>AJAX TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
@import "ajax.css";
</style>
</head>
<body>
<div id="front" onmousemove='mousemove(event);' onmouseout='mouseexit(event);'>
    <div id="content" style="position: absolute; top: 50px; left: 42px; z-index: 1;"><p>test</p></div>
<img src="Default.png" />

  <div class='flip' id='flip' onclick='showBack(event);' onmouseover='enterflip(event);' onmouseout='exitflip(event)';></div>

  <div class='flip' id='fliprollie'></div>


<div id="back">
   <img span="backgroundImage" src="Back.png" />
</div>
</body>
</html>
<script type="text/javascript" src="ajax.js" charset="utf-8"></script>


The results in Dashboard show "This is the response: Null".

The results in all the browsers I tested this file in show "This is the response: Everglades on the Bay,39"

As you can see, the XMLHttpRequest is obviously working, albeit not in Dashboard. Also, note that I am running 10.4.5 - everything is up-to-date.

And in case you are wondering why I'm searching for browser compatibility for the request object, I did this so I could test it in Internet Explorer, in which it worked fine.

As you can see, this is all extremely simple. Am I overlooking something ridiculously stupid? Or is there some sort of issue with Dashboard that won't allow this?

Thanks for all your help!
View user's profile Send private message Send e-mail Widgets
HotPantsOn



Joined: 24 Feb 2006
Posts: 5

Posted: Fri Feb 24, 2006 - 11:15 pm    Post subject: Reply with quote

Well that was quick. Looks like all I had to do was enable network access in the info.plist file. I hope this helps anyone else running into the same problem.

Cheers!
View user's profile Send private message Send e-mail 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