56 lines
1.6 KiB
JavaScript
Vendored
56 lines
1.6 KiB
JavaScript
Vendored
$('#addIpBtn').click(function(evt){
|
|
|
|
evt.preventDefault();
|
|
console.log('heere');
|
|
|
|
$('#newIpModal').modal('show');
|
|
});
|
|
|
|
|
|
$('#newIpForm').submit(function(evt){
|
|
evt.preventDefault();
|
|
var formData = new FormData($(this)[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: base_url + '/mnos/ip_store',
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$("#newIpForm")[0].reset();
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'IP Address added successfully',
|
|
});
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 5000);
|
|
}
|
|
else if (data.code > 5) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
},
|
|
error: function(error){
|
|
var output = $.parseJSON(error.responseText);
|
|
console.log(output.errors);
|
|
$('#ipNotifyArea').removeClass('hidden');
|
|
$('#ipNotifyArea').addClass('alert alert-danger');
|
|
$.each(output.errors, function (key, value) {
|
|
console.log(value[0]);
|
|
$('#ipNotifyArea').text(value[0]);
|
|
});
|
|
}
|
|
});
|
|
}); |