मैंने लॉग इन करने वाले उपयोगकर्ताओं के लिए एक अलर्ट संदेश जोड़ने का प्रयास किया। जब डेटा अच्छा होता है, तो एक सफल लॉगिन दिखाई देगा और जब गलत नाम या पासवर्ड गलत होगा

function mesajConectare(response) {
    if (response.statusLogged == "Succes login") {
        var da = `<div class="alert alert-success alert-dismissible fade show">
        <strong>Success!</strong> Your message has been sent successfully.
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>`
    } else {
        var da = `<div class="alert alert-success alert-dismissible fade show">
        <strong>Success!</strong> Your message has been sent successfully.
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>`
    }
    jQuery('.msgConectare').text(da);

}

जावास्क्रिप्ट:

 success: function (response) {
        var msg = "";
        if (response.statusLogged == "Succes login") {
            window.location = "/pages/admin/index.html";
            window.localStorage.setItem('firstName', response.firstName);
            window.localStorage.setItem('lastName', response.lastName);

            window.localStorage.setItem('userId', response.userId);
            window.localStorage.setItem('email', response.email);
            window.localStorage.setItem('UserName', response.userName);
            window.localStorage.setItem('password', response.password);
            mesajConectare(response);

        } else {
            msg = "Invalid username and password!";
            console.log(msg);
            mesajConectare(response);
        }

    }

एचटीएमएल

<body class="hold-transition login-page bs-example">
<div class="login-box">
    <div class="login-logo">
        <a href=""><b>Licenta</b>2019</a>
    </div>
    <!-- /.login-logo -->
    <div class="card">
        <div class="card-body login-card-body">
            <p class="login-box-msg">Autentificate in contul personal</p>

            <div class="input-group mb-3">
                <input id="UserName" type="email" class="form-control" placeholder="Email">
                <div class="input-group-append">
                    <div class="input-group-text">
                        <span class="fas fa-envelope"></span>
                    </div>
                </div>
            </div>
            <div class="input-group mb-3">
                <input id="password" type="password" class="form-control" placeholder="Password">
                <div class="input-group-append">
                    <div class="input-group-text">
                        <span class="fas fa-lock"></span>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-8">
                    <div class="icheck-primary">
                        <input type="checkbox" id="remember">
                        <label for="remember">
                            Memoreaza datele
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-4">
                    <button id="login" type="submit" class="btn btn-primary btn-block btn-flat">Conectare</button>
                </div>
                <!-- /.col -->
            </div>

            <div class="social-auth-links text-center mb-3">
                <div class="msgConectare">

                </div>

            </div>

            <!-- /.social-auth-links -->

            <p class="mb-1">
                <a href="#">Mi-am uitat parola</a>
            </p>
            <p class="mb-0">
                <a href="register.html" class="text-center">Utilizator nou</a>
            </p>
        </div>
    </div>
        <!-- /.login-card-body -->
    </div>



<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script src="/js/functii.js">
    jQuery.noConflict();
</script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.js"></script>

मेसजकोनेक्टेयर

 function mesajConectare(response) {
    if (response.statusLogged == "Succes login") {
        var da = `<div class="alert alert-success alert-dismissible fade show">
        <strong>Success!</strong> Your message has been sent successfully.
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>`
    } else {
        var da = `<div class="alert alert-success alert-dismissible fade show">
        <strong>Success!</strong> Your message has been sent successfully.
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>`
    }
    jQuery('.msgConectare').text(da);
    }
0
Bogdan 10 अक्टूबर 2019, 12:55

1 उत्तर

सबसे बढ़िया उत्तर

jQuery('.msgConectare').text(da); के बजाय jQuery('.msgConectare').html(da); का उपयोग करें

0
ASHMIL HUSSAIN K 10 अक्टूबर 2019, 13:00