Skip to content

Instantly share code, notes, and snippets.

@cesjam7
Forked from anonymous/validar_formulario_upload.js
Last active February 14, 2017 15:40
Show Gist options
  • Save cesjam7/aa96e1fd60ce7757efdf1e366638de71 to your computer and use it in GitHub Desktop.
Save cesjam7/aa96e1fd60ce7757efdf1e366638de71 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$(".submit_btn_enviar").click(function(evt) {
evt.preventDefault();
var postid = $(this).attr('data');
var id = jQuery("#idpost-" + postid).val();
alert(id);
// declaro la variable formData e instancio el objeto nativo de javascript new FormData
var formData = new FormData(document.getElementById("frmSubir_"+id));
// declaro la variable ruta
var ruta = '/wp-content/themes/acosa/enviar_cv.php';
// iniciar el ajax
$.ajax({
url: ruta,
// el metodo para enviar los datos es POST
type: "POST",
// colocamos la variable formData para el envio de la imagen
data: formData,
contentType: false,
processData: false,
beforeSend: function()
{
$('#contact_results_'+id+'').prepend('<img src="/wp-content/themes/acosa/ajax-loader.gif" />');
},
success: function(data)
{
$('#contact_results_'+id+'').fadeOut("fast",function(){
$('#contact_results_'+id+'').html(data);
});
$('#contact_results_'+id+'').fadeIn("slow");
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment