错误消息AJAX

I need to add an error popup message, but I really can't find how to do this. You can help me? This is the code:

if ($(current).attr("id") == "payment-page") {
                                $.ajax({
                                    url: 'https://openiban.com/validate/' + $("#iban").val(),
                                    success: function (data) {
                                        if (data.valid) {
                                            generatePDF(true);
                                            run();
                                        }

                                    },
                                    error: function(data) {
                                      // TODO: add better error for user
                                    },
                                    timeout: 3000
                                });
                            } else {
                                run();
                            }

I tried some codes for error function, but nothing is working.

You could use a jQuery Plugin like jquery-confirm (https://craftpip.github.io/jquery-confirm/) to create the popup for you.

Add the plugin to your app following the installation instructions and change your code to something like this:

if ($(current).attr("id") == "payment-page") {
    $.ajax({
        url: 'https://openiban.com/validate/' + $("#iban").val(),
        success: function(data) {
            if (data.valid) {
                generatePDF(true);
                run();
            }
        },
        error: function(data) {
            $.confirm({
                title: 'Encountered an error!',
                content: 'Error message',
                type: 'red'
            });
        },
        timeout: 3000
    });
} else {
    run();
}

Check this fiddle https://jsfiddle.net/o2gxgz9r/5745/