No entiendo porque no me está cogiendo la variable:
Código HTML:
Ver original<div id="contenedorcambiaravatar" class="container" style="display:none"> <form id="formcambiaravatar" enctype="multipart/form-data" method="POST"> <input type="file" name="imagen" id="imagen"> <input class="btn btn-default" type="submit" style="float:left;margin-top:5px;> <i id="loader" class="fa fa-spinner fa-pulse" style="display:none;"></i>
Código Javascript
:
Ver original$("#formcambiaravatar").submit(function (e) {
e.preventDefault();
$.ajax({
type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
url: 'subiravatar', // the url where we want to POST
data: $('#formcambiaravatar').serialize(), // our data object
dataType: 'json',
beforeSend: function () {
$("#loader").show();
}
}).success(function (data) {
$("#loader").hide();
});
En cambio si añado ahí en el formulario un input text, sí que me la coge