$(function(){
// see http://malsup.com/jquery/form/ for info about ajaxForm()
$("#apiForm").ajaxForm({
dataType: 'json',
success: function(data) {
swal("API response:\n(token will be stored in local storage)\n"+JSON.stringify(data));
// store token in local storage
localStorage.setItem('token', data.token);
},
error: function(data) {
swal("Error:\n"+JSON.stringify(data));
}
});
});