im using CI in my project and currently i have a issue. i am sending a values through jquery serialize but the code is not working …
here is the code.. in my view my form id is ‘form’ and button type is submit and id is ‘btn’ ..
<script>
$('#btn').click(function() {
form = $("#form").serialize();
$.ajax({
type: "POST",
url: "<?php echo site_url('categoryController/addCategory'); ?>",
data: form,
success: function(data){
alert('Successful!);
}
});
return false; //stop the actual form post !important!
});
Use the
event.preventDefault()method to prevent the form from submitting. It is also important to note that there is an unterminated String literal within the script.