I have a problem, I want to use jquery ajax to simply input database.
this my code tes.php
<script src='jquery.js'></script>
<script>
$(document).ready(function(){
//alert('$');
$('.SAVE').click(function(){
//alert('&');
var name = $('.NAME').val();
var alamat = $('.ALAMAT').val();
//alert(name);
//alert(alamat);
$.ajax({
type:"POST",
dataType:"json",
url:"tes2.php",
data:$('#COBA').serialize(),
success: function(response) {
alert(response);
},
});
});
});
</script>
<form id='COBA'>
<input type='text' name='NAME' class='NAME' value='septiyo'><br>
<input type='text' name='ALAMAT' class='ALAMAT' value='semambung'><br>
<input type='submit' value='SAVE' name='SAVE' class='SAVE'>
</form>
and tes2.php
<?php
$name = $_POST['NAME'];
$alamat = $_POST['ALAMAT'];
print_r($_POST);
?>
But it dont work, I Hope can Get the data On tes2.php so I can Process it with query.
can anyone help me to fix this?
Thanks in Advance