Javascript Ajax dataReady通过数据对象显示自定义警报

Javascript Ajax dataReady通过数据对象显示自定义警报,javascript,jquery,ajax,Javascript,Jquery,Ajax,如何自定义要显示的数据对象:电子邮件地址已注册!通过javascript警报。 数据从servlet获取一个布尔值,现在如果电子邮件已经在数据库中,它将显示true或false $('#emailInput').on('change', function() { $.ajax({ url: "Controller", cache: false, dataType: "tex

如何自定义要显示的数据对象:电子邮件地址已注册!通过javascript警报。
数据从servlet获取一个布尔值,现在如果电子邮件已经在数据库中,它将显示true或false

 $('#emailInput').on('change', function() {

            $.ajax({
                url: "Controller",
                cache: false,
                dataType: "text",
                data: "command=checkEmail&email=" + $(this).val(),
                success: dataReady

            });
        });


        $(window).load(function() {
            $('.log-out').fadeIn(200);
        });
    });

    function dataReady(data) {
        alert("Data: " + data);

        if (data == true){
            alert(data);
            $("#emailExists").html("The email address has already been registered!");
        }
    }

你想要这个,我来帮你

if (data == true){
    alert("The email address has already been registered!");
    $("#emailExists").html("The email address has already been registered!");
}

不管怎样,如果文本输入有任何变化,您都会发送一个AJAX请求,这不是一个很好的工作,请求太多,我会检查长度或其他内容。

函数正确返回true或false?。。。另一个功能看起来不错。我们正在后端检查此电子邮件是否已经存在,以及它是否已经存在。数据是否为真,它应该显示为已经存在。但是我们只允许让一个客户在后端返回true或“true”。。因为有不同之处。emailExists是有效id?请找出原因。当使用servlet时。我使用了PrintWriter和out.println,但应该是out-print-它不应该生成新行