function userCreate() { var action = "http://localhost:8080/api/users"; var postData = {}; postData.mail = $('#createEmail').val(); postData.user = $('#createUsername').val(); postData.first = $('#createFirst').val(); postData.last = $('#createLast').val(); $.post(action, postData, function (data) { console.log("In post cb", data) // If there is an error message, but no HTTP error status. if (data.error) { $('.alert').html(data.error); $('.alert').alert(); } else { $('.alert').html("All OK"); $('.alert').alert(); } }, 'json').fail(function (error) { // If there is a HTTP error status console.log('In fail', error.responseJSON) $('.alert').html(error.responseJSON.error) $('.alert').alert() }); } $(document).ready(function () { // $('.alert').alert('close'); });