--
MahiroAndo - 2012-11-14
Thank you Mahiro for contributing this plugin!
I created supporting topics
JqPlotPluginDev,
JqPlotPluginAppraisal and
Support.JqPlotPlugin. I also tagged the plugin topic.
--
PeterThoeny - 2012-11-14
The plugin works fine here for data inside thelocal TWIki realm. One of users has requested to include a JSON file from another domain.
Is there any precondition to being able to read a JSON file that is hosted at an server outside the realm of Twiki domain ? This is an example code:
<div id='chart_r' style='height:280px; width: 500px;'></div>
<script>
$.getJSON('http://www.anotherdomain.com/test.json', function (data) {
$.jqplot('chart_r', [data.test, data.troll]);
});
</script>
--
Peter Jones - 2013-07-17
Hi Peter Jones,
That's an interesting use case. In our company, we have a kind of generic way to work around the cross-domain issue with a custom script
connect under TWiki cgi-bin, so you can write:
$.getJSON('%SCRIPTURLPATH{connect}%?url=http://www.anotherdomain.com/test.json', ...);
It can be implemented with
TWiki::Func::getExternalResource($url, [], {handlers => {...}}) where
handlers => {
response_header => sub {print $_[0]->headers->as_string, "\n"; return},
response_data => sub {print $_[3]; return 1},
};
Alternatively, the below may work:
<script>
var data = $.parseJSON('%INCLUDE{"http://www.anotherdomain.com/test.json"}%');
$.jqplot('chart_r', [data.test, data.troll]);
</script>
Hope this helps.
--
Mahiro Ando - 2013-07-18