Serveur preprod f0c0c48223 first push
2016-04-14 16:14:31 +02:00

49 lines
846 B
JavaScript
Executable File

$(function(){
var that = this;
that.initAdd = function(){
$('.add_newsletter').on('click', function(){
var property = {
'ajax': 1,
'token': token_newsletter,
'action': 'addForm',
};
$.ajax({
type: 'GET',
url: currentIndex,
dataType : "json",
data : property,
success: function(data) {
if(data.hasError) {
displayError(data.error);
}
else {
$.fancybox(data);
}
},
error: function() {
displayError('An error occured in PHP');
}
});
});
$('body').on('submit', '#form_add', function(){
if($(this).find('input[name=name]').val() == '') {
displayError('Input newsletter name');
return false;
}
});
}
that.init = function(){
that.initAdd();
}
$(document).ready(function(){
that.init();
})
});