timeline: receive JSON data from a JSP instead of from an input file

126 views
Skip to first unread message

Trudy

unread,
Mar 25, 2011, 12:28:29 PM3/25/11
to SIMILE Widgets
I'd like to connect to a JSP and receive timeline data from that, but
I am having trouble getting anything back from the JSP. Here is my
code:

In the html file:

tl.loadJSON("http://localhost:8080/nss-web/getganttresults.jsp",
function(json, url) { eventSourceALL.loadJSON(json, url); });



The problem I am seeing is that the response comes back with a normal
status, but responseText is empty. I have the debugger parked on
f(eval('(' + xmlhttp.responseText + ')'), url) as shown below.
responseText is always an empty string.

Timeline._Impl.prototype.loadJSON = function(url, f) {
var tl = this;
var fError = function(statusText, status, xmlhttp) {
alert("Failed to load json data from " + url + "\n" + statusText);
tl.hideLoadingMessage();
};
var fDone = function(xmlhttp) {
try {
f(eval('(' + xmlhttp.responseText + ')'), url);
} finally {
tl.hideLoadingMessage();
}
};
this.showLoadingMessage();
window.setTimeout(function() { SimileAjax.XmlHttp.get(url, fError,
fDone); }, 0);
};


Any ideas on what I can try next? I checked the 'Net' tab in firebug,
and it shows that the jsp got 125KB of data back in about 3 seconds,
which is exactly what I would expect. But the returned data is not in
the response.

Thanks in advance!
--Trudy

Trudy

unread,
Mar 25, 2011, 12:30:00 PM3/25/11
to SIMILE Widgets
Sorry, bad cut and paste there. The message should look like this...

I'd like to connect to a JSP and receive timeline data from that, but
I am having trouble getting anything back from the JSP. Here is my
code:

In the html file:

tl.loadJSON("http://localhost:8080/nss-web/getganttresults.jsp",
function(json, url) { eventSourceALL.loadJSON(json, url); });

The problem I am seeing is that the response comes back with a normal
status, but responseText is empty. I have the debugger parked on
f(eval('(' + xmlhttp.responseText + ')'), url) as shown below.
responseText is always an empty string.

Timeline._Impl.prototype.loadJSON = function(url, f) {
var tl = this;
var fError = function(statusText, status, xmlhttp) {
alert("Failed to load json data from " + url + "\n" + statusText);
tl.hideLoadingMessage();
};

Any ideas on what I can try next? I checked the 'Net' tab in firebug,
and it shows that the jsp got 125KB of data back in about 3 seconds,
which is exactly what I would expect. But the returned data is not in
the response.

Thanks in advance!
--Trudy

mleden

unread,
Mar 25, 2011, 1:58:13 PM3/25/11
to SIMILE Widgets
Hi Trudy,

Just a guess here, but have you checked the header of the
getganttresults.jsp?

I'm using PHP on the server-side to generate my JSON result sets and,
as I recall, this tripped me up for a while. Anyway, this is what I
include:
header("Content-Type: application/json; charset=utf-8");

Aside from that, the only other advice, probably something that you've
done already, is to ensure that the URL/jsp returns what you would
expect directly from within the browser.

HTH,
-Mark

Trudy

unread,
Mar 31, 2011, 6:27:17 PM3/31/11
to SIMILE Widgets
Thanks Mark - that fixed it!

--Trudy

Zulkifli Said

unread,
Jan 30, 2012, 2:43:45 AM1/30/12
to simile-...@googlegroups.com
hai mladen, can you give me a script php to generate JSON result sets? thanks...
Reply all
Reply to author
Forward
0 new messages