Ajax form submission not happening.
view:
<form method="post" name="addwishlists" id="addwishlists" enctype="multipart/form-data" >
<input type="hidden" name="deal_id" value="<?php echo $deal_id; ?>" >
<input type="hidden" name="cust_id" value="<?php echo $cust_id; ?>">
<input type="submit" value="Add Wishlist" id="addwishlist" class="btn btn-primary" />
</form>
My code is:
<script> //no need to specify the language
$(document).ready(function(){
$("#addwishlist").click(function(e){ // passing down the event
$.ajax({
url:'<?php echo base_url();?>add-wishlist',
type: 'POST',
data: $("#addwishlists").serialize(),
success: function(){
alert("wishlist added");
$('#deal_id').val('');
$('#cust_id').val('');
},
error: function(){
alert("Fail")
}
});
e.preventDefault(); // could also use: return false;
//return false;
});
});
</script>