私は非常に奇妙な問題に遭遇しました。JSON データとして送り返すために json_encode を使用している PHP ページから返される情報があります。呼び出しページでそれを受信すると、応答は正しいです(firebug内から応答を表示します)。
$.ajax 関数でデータを受け取った後にデータを console.log にすると、応答にはなかった変数 (y0) が追加されます。dataType は JSON に設定されており、私の PHP ページには JSON ヘッダー タイプが設定されています。この問題は、データを解析する ajax で発生しているようです。
以下は、私の ajax と、応答とログに記録されたデータです。
//AJAX メソッド
$.ajax({
url : 'includes/build_graphs.php',
data : 'file='+href,
type : 'post',
dataType : 'json',
beforeSend : function(){},
success : function(data){
console.log(data);
var series_data = [];
for(var i=0; i<data.length; i++){
series_data.push({
name: data[i].name+'[VPD]',
data: data[i].vpd,
color: palette.color()
});
}//for
console.log(series_data);
create_graph(series_data);
}
});
//PHP からの Firebug 応答
[{"name":"Project 1","vpd":[{"x":1348696800,"y":0},{"x":1348783200,"y":0},{"x":1348869600,"y":16},{"x":1348956000,"y":1},{"x":1349042400,"y":1},{"x":1349128800,"y":20},{"x":1349215200,"y":1},{"x":1349301600,"y":17},{"x":1349388000,"y":10},{"x":1349474400,"y":23},{"x":1349560800,"y":0},{"x":1349647200,"y":58}]},{"name":"Project 2","vpd":[{"x":1348696800,"y":7},{"x":1348783200,"y":0},{"x":1348869600,"y":7},{"x":1348956000,"y":0},{"x":1349042400,"y":0},{"x":1349128800,"y":12},{"x":1349215200,"y":2},{"x":1349301600,"y":17},{"x":1349388000,"y":11},{"x":1349474400,"y":10},{"x":1349560800,"y":0},{"x":1349647200,"y":20}]},{"name":"Project 3","vpd":[{"x":1348696800,"y":3},{"x":1348783200,"y":18},{"x":1348869600,"y":23},{"x":1348956000,"y":1},{"x":1349042400,"y":1},{"x":1349128800,"y":11},{"x":1349215200,"y":17},{"x":1349301600,"y":50},{"x":1349388000,"y":22},{"x":1349474400,"y":39},{"x":1349560800,"y":0},{"x":1349647200,"y":34}]},{"name":"Project 4","vpd":[{"x":1348696800,"y":0},{"x":1348783200,"y":66},{"x":1348869600,"y":13},{"x":1348956000,"y":0},{"x":1349042400,"y":0},{"x":1349128800,"y":3},{"x":1349215200,"y":3},{"x":1349301600,"y":9},{"x":1349388000,"y":71},{"x":1349474400,"y":48},{"x":1349560800,"y":0},{"x":1349647200,"y":80}]},{"name":"Project 5","vpd":[{"x":1348696800,"y":6},{"x":1348783200,"y":2},{"x":1348869600,"y":9},{"x":1348956000,"y":0},{"x":1349042400,"y":0},{"x":1349128800,"y":2},{"x":1349215200,"y":2},{"x":1349301600,"y":20},{"x":1349388000,"y":4},{"x":1349474400,"y":9},{"x":1349560800,"y":0},{"x":1349647200,"y":22}]},{"name":"Project 6","vpd":[{"x":1348696800,"y":0},{"x":1348783200,"y":0},{"x":1348869600,"y":0},{"x":1348956000,"y":0},{"x":1349042400,"y":0},{"x":1349128800,"y":0},{"x":1349215200,"y":0},{"x":1349301600,"y":0},{"x":1349388000,"y":0},{"x":1349474400,"y":0},{"x":1349560800,"y":0},{"x":1349647200,"y":21}]},{"name":"Project 7","vpd":[{"x":1348696800,"y":0},{"x":1348783200,"y":0},{"x":1348869600,"y":0},{"x":1348956000,"y":0},{"x":1349042400,"y":0},{"x":1349128800,"y":17},{"x":1349215200,"y":2},{"x":1349301600,"y":48},{"x":1349388000,"y":14},{"x":1349474400,"y":32},{"x":1349560800,"y":0},{"x":1349647200,"y":35}]},{"name":"Project 8","vpd":[{"x":1348696800,"y":13},{"x":1348783200,"y":0},{"x":1348869600,"y":23},{"x":1348956000,"y":0},{"x":1349042400,"y":1},{"x":1349128800,"y":15},{"x":1349215200,"y":2},{"x":1349301600,"y":27},{"x":1349388000,"y":14},{"x":1349474400,"y":32},{"x":1349560800,"y":0},{"x":1349647200,"y":72}]}]
//解析された JSON からのエントリ (残念ながら、画像を投稿できないため、firebug からコピーを貼り付けました) //エントリ 9 に関してここで奇妙なことが起こっていることに気付きましたが、これは firebug であるか、実際に問題である可能性があります
name="Project 1",
vpd=[
Object{
x=1348696800,
y=0,
y0=0
},
Object{
x=1348783200,
y=0,
y0=0
},
Object{
x=1348869600,
y=16,
y0=0
},
9more...
]
0 = Object{
x=1348696800,
y=0,
y0=0
}
1 = Object{
x=1348783200,
y=0,
y0=0
}
2 = Object{
x=1348869600,
y=16,
y0=0
}
3 = Object{
x=1348956000,
y=1,
y0=0
}
4 = Object{
x=1349042400,
y=1,
y0=0
}
5 = Object{
x=1349128800,
y=20,
y0=0
}
6 = Object{
x=1349215200,
y=1,
y0=0
}
7 = Object{
x=1349301600,
y=17,
y0=0
}
8 = Object{
x=1349388000,
y=10,
y0=0
}
9 = "this.9"
10 = Object{
x=1349560800,
y=0,
y0=0
}
11 = Object{
x=1349647200,
y=58,
y0=0
}
前もって感謝します。