嗨,我正在玩OpenFlash-图表,虽然一些php图显示得很好,但我在javascript中的最新代码中出现了以下错误:
Open Flash Chart
IO ERROR
Loading test data
Error #2032
This is the URL that I tried to open:../../data-files/y-axis-auto-steps.txt我理解,这是一个普遍的错误-msg,它显示出来,例如,如果数据没有正确地发送到ofc。
调用来自以下函数:
function open_flash_chart_data(){
return JSON.stringify(data);
}
function plot_graph(checkedBoxes, theitems, thetrack, thedates, thevalues, trackCount){
top.restoreSession();
$.ajax({ url: 'graph_include.php',
type: 'POST',
data: { dates: thedates,
values: thevalues,
items: theitems,
track: thetrack,
thecheckboxes: checkedBoxes
},
dataType: "json",
success: function(returnData){
// place the raw graph data in the data variable
var data=returnData;
swfobject.embedSWF('open-flash-chart.swf',"graph"+trackCount, "650", "200", "9.0.0");
$('#graph'+trackCount).show();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);
}
}); // end ajax query
}我的函数plot_graph()是用适当的变量调用的,但是我得到了#2032错误
我的解决办法:
在AJAX调用的graph_include.php中,我将echo $chart->toPrettyString();写入一个名为"plot.json“的文件中,如下所示:
$fh = fopen("plot.json", 'w');
$chartjson = $chart->toPrettyString();
fwrite($fh, $chartjson);
fclose($fh);然后,将成功回调更改为以下内容,以便从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"}); 这个很好,我得到了一个合适的图表。
所以,我猜错误2032肯定和我的ajax调用有关.
请有人看看我在ajax上做错了什么,因为我需要这个javascript/ajax来获得一些传递给php.
发布于 2014-03-18 21:40:47
我想这会有帮助的
在ajax函数之外,declair设置如下所示的变量:
var flashvars = {};在AJAX--成功调用中,编写:
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); 在这里工作..。
https://stackoverflow.com/questions/22457962
复制相似问题