I'm having an issue with the javascript below in which the $.ajax
call is not being called. The alert('foo')
does happen, but then the data call is completely skipped and the callback is never reached (never get alert('success!')
. I don't completely understand callbacks, but this seems like it should be working.
Edit
Edited the script to where I currently stand, as I've read this way is better practice. Still, I can step in to authenticate()
, it breaks on url:[...]
, but then never actually makes the ajax call. I've tried removing the return just to see if that's the problem, but it's producing the same result.
define(["jQuery", "kendo", "modernizr", "app/environment"], function ($, kendo, modernizr, environment) {
var authenticate = function (username, password) {
return $.ajax({
url: environment.apiConnection + '/canlogin?userid=' + username + '&password=' + password,
type: 'get',
dataType: 'jsonp'
});
}
var canLogin = function(data) {
alert('good');
}
return {
viewModel: kendo.observable({
username: null,
password: null,
authenticate: function () {
var username = this.get('username'),
password = this.get('password');
authenticate(username, password).done(canLogin);
}
})
}
});