次のような配列を持つphpファイルがあります。
$selectShiftarray = array();
$shift=$_POST['selectShift'];
if ($shift)
{
foreach ($shift as $value)
{
array_push($selectShiftarray,$value);
}
}
値を別の php ファイルに渡すには、AJAX 内の $selectShiftarray にアクセスする必要があります。
$.ajax({
type: 'POST',
url: '../c/sampleTest.php', //data: {data = <?php $POST['selectShift'] ?> },//"id=78&name=Allen",
dataType: 'json',
success: function (json) {
//alert('successful');
$.plot($("#placeholder"), json, {
series: {
stackpercent: true,
bars: {
show: true,
barWidth: 0.6,
align: "center"
}
},
xaxis: {
tickSize: 1
},
yaxis: {
max: 100,
tickFormatter: function (v, axis) {
return v.toFixed(axis.tickDecimals) + '%'
}
}
});
}
});
AJAXのデータフィールドの配列値をsampleTest.phpに渡して計算してみました。
2 つの php ファイル間で配列値を直接渡す場合、現在の php ファイル内に sampleTest.php を含めたいと思います。私の要件は、php ファイル内に sampleTest.php ファイルを含めないことです。そのため、AJAX の POST メソッドを使用します。しかし、配列を sampleTest.php ファイルに渡すことができません。私はAJAXが初めてなので、この問題を解決できません。誰でもこの問題を解決するのを手伝ってくれますか?