I have tried answers from various questions here and also from examples on google, however, none seem to be workings not sure what I am doing wrong.
I have the following code
<form>
<input type="text" id="regoffice_1" value="<?php echo $result['regoffice_1'];?>">
<input type="hidden" name="companyid" value="1">
</form>
<script>
$("#regoffice_1").on("change", function() {
var itemVal = $("#regoffice_1").val();
var dataObj = {companyid: $("#companyid").val(), regoffice_1: $("#regoffice_1").val()};
processChange(dataObj);
});
function processChange(dataObj){
$.ajax({
type: "POST",
url: "inc/dataforms/test.php",
data: dataObj,
dataType: "text", // If you expect a json as a response
complete: function(data) {
var Resp = data.responseText;
console.log(Resp);
}
});
};
</script>
In the PHP file just a simple query
<?php
include('../config.php');
mysqli_query($dbc,"UPDATE `comp_companies` SET `regoffice_1` = '$_POST[regoffice_1]' WHERE `company_id` = '$_POST[companyid]'");
?>
Nice and simple .. however I'm getting no errors shown or anything shown in the console and no data being updated
What am I missing ??