我只想要一些建议,首先您的html页面代码应该喜欢-
<html><head> <script src="jquery-3.1.0.min.js"></script></head><body><form name="form" id="form_id"><input type="checkbox" id="boiler" name="boiler"><input type="checkbox" id="niamh" name="niamh"><button onclick="myFunction()">Update</button></form><script>function myFunction() { // it's like cumbersome while form becoming larger so comment following three lines // var boiler = document.getElementByName("boiler").value; // var niamh = document.getElementByName("niamh").value; // Returns successful data submission message when the entered information is stored in database. //var dataString = 'boiler=' + boiler + 'niamh=' + niamh;// AJAX pre to submit form. $.ajax({ // instead of type use method method: "POST", url: "updateDB.php", // instead dataString i just serialize the form like below this serialize function bind all data into a string so no need to worry about url endcoding data: $('#form_id').serialize(), cache: false, success: function(responseText) { // you can see the result here console.log(responseText) alert("ok"); } });}</script></body></html>现在我转向php代码:您在php中使用了两行代码
$boiler = (isset($_GET['boiler'])) ? 1 : 0;$niamh = (isset($_GET['niamh'])) ? 1 : 0;
$ _GET用于get方法,而$ _POST用于post方法,因此您在ajax中使用post方法,上面的代码行应该像
$boiler = (isset($_POST['boiler'])) ? 1 : 0;$niamh = (isset($_POST['niamh'])) ? 1 : 0;



