Skip to content

Instantly share code, notes, and snippets.

@prinick96
Created July 25, 2017 01:32
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 prinick96/abf46270369395c0c6fc3ce96df7434b to your computer and use it in GitHub Desktop.
Save prinick96/abf46270369395c0c6fc3ce96df7434b to your computer and use it in GitHub Desktop.
$('#idboton').click(function(e){
/* START Prevención de doble clic */
e.preventDefault();
/* END Prevención de doble clic */
var algo = new FormData();
var perfil = document.getElementById('id en el input de tipo file');
var file = perfil.files[0];
// Hay que cargar manualmente cada input, por id
algo.append('nombre de campo que se recibe en php',$('#id del input').val());
algo.append('perfil',file);
$.ajax({
type : "POST",
url : "api/ruta",
contentType:false,
processData:false,
data : algo,
success : function(obj) {
console.log(obj.success);
console.log(obj.message);
},
error : function() {
window.alert('ERROR, activar debug');
}
});
});
@Origamero
Copy link

gracias me ha funcionado al tiro!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment