Skip to content

Instantly share code, notes, and snippets.

@eboominathan
Created March 7, 2016 01:48
Show Gist options
  • Save eboominathan/1222a56353dda5d30fc5 to your computer and use it in GitHub Desktop.
Save eboominathan/1222a56353dda5d30fc5 to your computer and use it in GitHub Desktop.
Ajax code to submit form in Codeigniter
$('#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