私は今テストしているいくつかのajaxをセットアップしました、その背後にあるほとんどのアイデアは、ドロップダウンボックスからphpスクリプトにいくつかのデータを送信し、いくつかの計算を行ってから結果を返すことです、それはうまくいき、結果を返します、しかし、今では1つの結果を返送して出力するのではなく、複数の結果を返送して出力したいので、phpスクリプトに複数のデータを送信できるので、複数の結果を返送できると確信しています。
とにかく、それは最初の結果だけを送り返し、残りは送り返しません。
これがAJAXです
<script>
$("document").ready(function (){
$(".add_extension").change(function(){
var m = document.getElementById('meter_square');
var meter_square = m.options[m.selectedIndex].value;
var s = document.getElementById('story_height');
var story_height = s.options[s.selectedIndex].value;
$.ajax({
type: "GET",
url: "script.php",
data: { meter_square: meter_square, story_height: story_height },
dataType: "json",
statusCode: {
200: function (result, result2)
{
$("#expected_gain").html(result.value);
$("#house_price").html(result2.value2);
}
}
});
})
});
</script>
そしてここにphpスクリプトがあります
<?php
$meter_square = $_GET["meter_square"];
$story_height = $_GET["story_height"];
$result = $meter_square + $story_height;
$result2 = $meter_square * $story_height;
echo json_encode(array("value" => $result, "value2" => $result2));
?>
他のコードが必要な場合、または追加した機能しないコードを削除してほしい場合は、私がうまくいくと思っていたものからすでに試してみたことがわかります。それから私に知らせてください。
すべての助けをありがとう