submitHandler: function (form) {
var $form = $("#frmQuestion"), formData = new FormData(), params = $form.serializeArray();
$.each(params, function (i, val) {
formData.append(val.name, val.value);
});
var files = $("input[Type='file']");
for (var i = 0; i < files.length; i++) {
formData.append(files[i].name, $('#' + files[i].id).get(0).files[0]);
}
$.ajax({
url: '/Questions/SaveQuestion',
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
mimeType: "multipart/form-data",
beforeSend: function () { ShowCustomLoading(true); },
complete: function () { ShowCustomLoading(false); },
success: function (datas) {
var data = JSON.parse(datas)
if (data.Key == true) {
new PNotify({
text: data.Value,
delay: 1500,
type: 'success'
});
$("#divlist").show();
$("#divAdd").hide();
$("#jqTable").trigger('reloadGrid');
}
else {
new PNotify({
text: data.Value,
delay: 1500,
type: 'error'
});
}
}
});
}
var $form = $("#frmQuestion"), formData = new FormData(), params = $form.serializeArray();
$.each(params, function (i, val) {
formData.append(val.name, val.value);
});
var files = $("input[Type='file']");
for (var i = 0; i < files.length; i++) {
formData.append(files[i].name, $('#' + files[i].id).get(0).files[0]);
}
$.ajax({
url: '/Questions/SaveQuestion',
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
mimeType: "multipart/form-data",
beforeSend: function () { ShowCustomLoading(true); },
complete: function () { ShowCustomLoading(false); },
success: function (datas) {
var data = JSON.parse(datas)
if (data.Key == true) {
new PNotify({
text: data.Value,
delay: 1500,
type: 'success'
});
$("#divlist").show();
$("#divAdd").hide();
$("#jqTable").trigger('reloadGrid');
}
else {
new PNotify({
text: data.Value,
delay: 1500,
type: 'error'
});
}
}
});
}
No comments:
Post a Comment