【发布时间】:2021-06-14 20:37:42
【问题描述】:
我尝试编写在函数内部给出警告消息的代码,但成功或错误块似乎不起作用。
如何正确调用函数?我正在使用最新的 Ember 版本(3.2.5)。 这是我在应用程序/控制器中的 AJAX 代码
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);
}
});
},
}
});
【问题讨论】:
标签: jquery ajax servlets ember.js