// create model for controller
var model = new FormData();
model.append('Name', $.trim($contestForm.find('[name="nombre"]').val()) + ' ' + $.trim($contestForm.find('[name="apellido"]').val()));
model.append('Email', $.trim($contestForm.find('[name="email"]').val().toLowerCase()));
model.append('City', $.trim($contestForm.find('[name="cuidad"]').val()));
model.append('Title', $.trim($contestForm.find('[name="title"]').val()));
model.append('Description', $.trim($contestForm.find('[name="description"]').val()));
model.append('CountryCode', 'co');
model.append('Image', $contestForm.find('[name="file-es"]')[0].files[0]); // this has the file for sure
$.ajax({
url: '/Umbraco/api/ControllerName/CreateContestEntry',
type: 'POST',
dataType: 'json',
data: model,
processData: false,
contentType: false,// not json
complete: function (data) {
var mediaId = $.parseJSON(data.responseText); //?
},
error: function (response) {
console.log(response.responseText);
}
});
Monday 11 July 2016
Image upload through ajax
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment