0

Hi there I am playing with OpenFlash-Chart, while some php graphs are displayed properly, I get the following error with my latest code in 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

I understood, that this is a general error-msg, which shows up e.g. if data isn't sent properly to ofc.

The call comes from this function:

 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
 }

My function plot_graph() is called with proper variables, but I get Error #2032

My workaround:

in graph_include.php, which is called by AJAX, I write the echo $chart->toPrettyString(); into a file called "plot.json", like this:

$fh = fopen("plot.json", 'w');    
$chartjson = $chart->toPrettyString(); 
fwrite($fh, $chartjson);
fclose($fh);

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"});  

This works just fine and I get a proper chart.

So, I guess Error 2032 must have something to do with my ajax-call...

Could please someone have a look on what I am doing wrong with ajax, because I need this javascript/ajax thing to get some vars which are passed to php...

4

1 回答 1

1

我发现这会有所帮助:

在 ajax 函数之外,声明一个像这样的变量:

 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);  

这在这里工作......

于 2014-03-18T21:40:47.513 回答