以下のコードに問題があります。
jquery
var data = $('thisForm').serialize();
var msg = <?php echo computeAverage(data)?>;
alert(msg);
php
function computeAverage($data){
return $data;
}
データの実際の値ではなく、出力として「データ」(文字列)を取得しています。ちなみに、上記の jquery と php 関数を含む php ファイルは 1 つだけ使用します。
あなたの助けに感謝します。私は本当にこれを理解する必要があります。私はjqueryが初めてです。
返信ありがとうございます。PHP関数を別のファイルに配置する必要があることを考えると
jquery
var url = "myPhpFunction.php";
var data = $('thisForm').serialize();
$post(url,data, function(response)); // how can i get the reponse from my url?
php
function computeAverage($data){ // how to convert $data to an array?
return average; // how can i return the average back to my jquery?
}
誰でも私を助けることができますか?ありがとう