0

こんにちは、私は OpenFlash-Chart で遊んでいますが、一部の 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

これは、データが 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 が発生します

私の回避策:

graph_include.php、AJAX によって呼び出され、次のように " "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 呼び出しと関係があるに違いないと思います...

PHPに渡されるいくつかの変数を取得するには、このjavascript/ajaxが必要なので、誰かが私がajaxで間違っていることを見てください...

4

1 に答える 1

1

これが役立つことがわかりました:

ajax 関数の外で、次のように変数を宣言します。

 var flashvars = {};

AJAX-success-call 内に、次のように記述します。

 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 に答える