$(document).ready(function() { $(document).on('click', '#ctr-login', function(e) { e.preventDefault(); formSend('ctr-thisForm', 'login', function(e) { if (e.error == 0) { window.location.href = e.data.goto+'?token='+e.data.token; } else alert(e.message) }) }); })