Im beginner in JS & AJAX so please bear with me.
I use codeigniter framework in this project. I want to create a datepicker and passing its value through AJAX. This is the script :
<script>
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true
});
$("#btn_insert").click(function() {
var url = "<?php echo base_url();?>" + "index.php/backend/umat";
$.ajax({
type: 'POST',
url: url,
dataType: "json",
data: $('#my_form').serialize(),
success: function(data) {
alert(data);
},
error: function(xhr, status, error) {
/*var err = eval("(" + xhr.responseText + ")");
alert(err.Message);*/
alert("a");
}
});
});
});
</script>
The datepicker is already shown & working fine. However the AJAX is still not working. When i tried to alert the error (the one i commented in code), it doesnt alert anything. So i tried to alert("a");
and yes, "a"
is alerted so theres something wrong in the AJAX. The data is never alerted which means it never success.
Theres no error in the console. Im using chrome browser.
Any help is appreciated and please just ask me if you need something. Thanks :D