Skip to content

Instantly share code, notes, and snippets.

@anialamo
Last active March 28, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anialamo/6ec61799b279a38d80180764dffeb98c to your computer and use it in GitHub Desktop.
Save anialamo/6ec61799b279a38d80180764dffeb98c to your computer and use it in GitHub Desktop.
Clean or reset form with codeigniter after use set_value
I use AjaX, I tried these functions:
------------- JS --------------------------------
$('body').on('click','.register .clean',function(e){
$.ajax({
url: 'acceso-usuario/limpiar',
type: 'post',
success: function (response) {
console.log("La llamada ajax fue con éxito!");
},
error: function(xhr, status, error) {
console.log("Ocurrió un error: " + error);
},
});
});
------------------ ROUTES----------------------------------
$route['acceso-usuario/limpiar']['post'] = 'users/clear_form_data';
------------------ CONTROLLER -----------------------------
class Users extends CI_Controller {
....
public function clear_form_data()
{
unset($_POST);
$this->form_validation->clear_field_data();
$this->index();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment