hey guys. so i found the coding for submitting a form without refresh from a website( http://www.computersneaker.com/submit-a-form-without-page-refresh-in-php-using-jquery/) but its not working. i just copy pasted the code to test it out but it doesnt submit the data. I wanted to ask the owner but didnt find any commenting area.
<head>
<script>
$(document).ready(function(){
$('#formasset').on('submit',function(e) {
$.ajax({
url:'sheets.php',
data:$(this).serialize(),
type:'POST',
success:function(data){
console.log(data);
$("#success").show().fadeOut(5000); //=== Show Success Message==
},
error:function(data){
$("#error").show().fadeOut(5000); //===Show Error Message====
}
});
e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
});
});
</script>
</head>
<div id="tabs-2">
<form method="post" action="sheet.php" name="formasset" id="formasset">
<center><h2>Asset</h2></center>
<p id="check"></p>
<center><table border="1" rules="all" cellpadding="10px;" class="asset">
<thead>
<th>Asset</th>
<th>Value</th>
</thead>
<tr>
<td><b>Personal</b></td>
<td></td>
</tr>
<tr>
<td>House</td>
<td><input class="txtBox" placeholder="0" type="text" name="ahouse" value="<?php if(isset($_POST['ahouse'])){echo htmlentities($_POST['ahouse']);} ?>"/></td>
</tr>
<tr>
<td>Vehicle <dfn>(Car,Motorcycle etc)</dfn></td>
<td><input class="txtBox" placeholder="0" type="text" name="avehicle" value="<?php if(isset($_POST['avehicle'])){echo htmlentities($_POST['avehicle']);} ?>"/></td>
</tr>
<tr>
<td><b>Total</b></td>
<td><input type="text" id="assets" name="assettotal" placeholder="0" readonly value="<?php if(isset($_POST['assettotal'])){echo htmlentities($_POST['assettotal']);} ?>"/></td>
</tr>
</table></center>
<div style="margin-top:20px;"> <span id="error" style="display:none; color:#F00">Some Error!Please Fill form Properly </span> <span id="success" style="display:none; color:#0C0">All the records are submitted!</span><center> <input type="submit" value="Save" class="assetsave" name="assetsave" id="assetsave"></center></div>
</form>
</div>
sheets.php being the processing file, where all the queries and such are at, for this page.
I click on save and it All the records are submitted! appears but it the data isnt submitted into the database.
is it cause im using a tab layout??