Created
March 7, 2016 01:48
-
-
Save eboominathan/1222a56353dda5d30fc5 to your computer and use it in GitHub Desktop.
Ajax code to submit form in Codeigniter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#submit').click(function(){ | |
var formData = new FormData($('#form')[0]); | |
$.ajax({ | |
url: '<?php echo base_url();?>controller/method', | |
type: 'POST', | |
data: formData, | |
async: false, | |
success: function(data) { | |
alert('form submitted'); | |
$('#form')[0].reset(); | |
}, | |
error: function(data){ | |
alert('error'); | |
}, | |
cache: false, | |
contentType: false, | |
processData: false | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment