Sails.js套接字放入表单数据

时间:2015-04-24 12:03:16

标签: socket.io sails.js

我有一个标准表格。我想用它来存储数据。

io.socket.put('/user/3', data, function (data, jwres){
            //console.log(JSON.stringify(jwres));
        });

是否有一种干净而明智的方法可以将所有表单输入值传递到“数据”而无需手动构建JSON?

1 个答案:

答案 0 :(得分:1)

您可以尝试使用jQuery

来使用此模块

<?php $aircraftMake = mysqli_real_escape_string($conn, $_POST['marke']); $aircraftModel = mysqli_real_escape_string($conn, $_POST['model']); $engine = mysqli_real_escape_string($conn, $_POST['Motorisation']); ?> </head> <body> <?php $sql = "SELECT * FROM QuoteData WHERE aircraftMake = '$aircraftMake'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $row["aircraftMake"]. "<br>" . $row["aircraftModel"]. "<br>" . $row["engineModel"]. "<br>" . $row["overhauledEngineSteelCylinders"]. "<br>" . $row["overhauledEngineNickelCylinders"]. "<br>" . $row["overhauledEngineNewCylinders"]. "<br>" . $row["individualOverhauledSteelCylinder"]. "<br>" . $row["setOfFourOverhauledSteelCylinders"]. "<br>" . $row["individualOverhauledNickelCylinder"]. "<br>" . $row["setOfFourOverhauledNickelCylinders"]. "<br>" . $row["engineCoreValue"]. "<br>" . $row["note1"]. "<br>" . $row["note2"]. "<br>" . $row["note3"]. "<br>" . $row["OverhaulIncludes"]. "<br>" . "<br>" . $row["shippingToInclude"]; } } else { echo "0 results"; } $conn->close(); ?>

https://github.com/hongymagic/jQuery.serializeObject

你也可以实现自己的功能,这个链接会告诉你如何做到这一点。

http://forum.jquery.com/topic/serializeobject

相关问题