I tried writing code that gives the alert message inside the function but the success or error block seems doesn’t work.
How can I call the function properly? I'm using the latest Ember version (3.2.5). Here is my AJAX code in the app/controller
import Controller from '@ember/controller';
import $ from 'jquery';
export default Controller.extend({
actions: {
validateUser: function() {
let res = this;
var userName = this.get('username');
var userPassword = this.get('password');
$.ajax({
type: "POST",
url: "InsertServlet",
data: {
userId: userName,
password: userPassword
},
success: function(data) {
if (data == 1) {
alert('valid user');
} else {
alert("Invalid User");
}
},
error: function(xhr, status, error) {
alert(xhr.responseText);
}
});
},
}
});
Aucun commentaire:
Enregistrer un commentaire