Dear folks,
I get an Error #2032 when I try to embed an ofc via a $AJAX-success-callback
This is my javascript:
function open_flash_chart_data(){
return JSON.stringify(data);
}
function plot_graph(theitems, trackCount){
$.ajax({ url: 'graph_include.php',
type: 'POST',
data: { items: theitems
},
dataType: "json",
success: function(returnData){
// place the raw graph data in the data variable
var data=returnData;
//alert(JSON.stringify(data));
swfobject.embedSWF('open-flash-chart.swf',"graph"+trackCount, "650", "200", "9.0.0");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);
}
}); // end ajax query
}
I don't know why this gives me an Error 2032, because var data has valid data.
In graph_include.php, which is called by AJAX, I write the echo $chart->toPrettyString(); into a file called "plot.json", like this:
Then a changed the success callback into this, in order to fetch data from plot.json:
success: function(returnData){
// graph_include.php writes the $chart->toPrettyString();
// into file "plot.json" inside of the track_anything folder
// we just fetch these data from that file, as
// var data=returnData
// don't seem to work here
// (open-flash-chart won't find var data for some reason)
swfobject.embedSWF('open-flash-chart.swf',
"graph"+trackCount, "650", "200", "9.0.0","",{"data-file":"plot.json"});
which works without any problems.
Instead of writing something to the filesystem, I would be very interested in a correct AJAX-Solution, passing var data directly to ofc2.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
outside of the ajax function, declair a variable like this:
var flashvars = {};
inside the AJAX-success-call, write:
success: function(returnData){
//we need to set both,
// data and flashvars.ofc
data=returnData;
flashvars.ofc = returnData;
swfobject.embedSWF('openflashchart/open-flash-chart.swf',
"graph"+trackCount, "650", "200", "9.0.0","",flashvars);
never mind
;)
Last edit: produnis 2014-03-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear folks,
I get an Error #2032 when I try to embed an ofc via a $AJAX-success-callback
This is my javascript:
I don't know why this gives me an Error 2032, because
var data
has valid data.In
graph_include.php
, which is called by AJAX, I write theecho $chart->toPrettyString();
into a file called "plot.json
", like this:Then a changed the success callback into this, in order to fetch data from plot.json:
which works without any problems.
Instead of writing something to the filesystem, I would be very interested in a correct AJAX-Solution, passing
var data
directly to ofc2.I figured out that this will help:
outside of the ajax function, declair a variable like this:
inside the AJAX-success-call, write:
never mind
;)
Last edit: produnis 2014-03-23