I can't understand why this code doesn't work with PUT method and only works with POST
$.ajax({
xhr: function(){
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt){
uploadProgress(evt);
}, false);
xhr.addEventListener("progress", function(evt){
console.log('down');
}, false);
return xhr;
},
url : 'upload',
type: 'PUT',
data: data,
cache: false,
dataType: 'json',
processData: false,
contentType: false,
success: function(data, textStatus, jqXHR){
console.log(textStatus);
},
error: function(jqXHR, exception){
alert("error --'");
}
});
When on type
I have POST, uploading works, but it's doesn't works with PUT :X
And there is a way to upload file via PUT without submitting a form?
Because code like that doesn't works:
$('#file-input').on('change', prepareUpload);
var files;
function prepareUpload(event){
files = event.target.files;
$.each(files, function(key, value){
data.append(key, value);
});
$.put(
$(this).parent().attr('action'),
data,
onAjaxSuccess_s
)
}