登录并将 div 部分更改为“welcome $username”

发布于 2024-10-02 22:58:46 字数 176 浏览 0 评论 0原文

我使用 div 显示用户名/密码/提交

还使用 AJAX 通知“登录无效”而不刷新页面

我需要做的是,

如果登录成功,隐藏用于登录的 div 部分的元素,然后显示“欢迎$username”在同一个 div 中。

(无需重新加载任何页面)

有人可以帮助我吗?

I am using div to display username/password/submit

Also using AJAX to inform "login invalid" without refreshing page

What I need to do is,

If login success, hide the elements of div section that used to log in, then display "welcome $username" in the same div.

(Without any page reloading)

Could anybody help me please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气尐潴 2024-10-09 22:58:47

使用 jQuery 的 post 方法:

$.post(
    '/url/to/post/login/details/to/',
    $('#login-form').serilaize(),
    function(data) {
        // hide the existing div and add a paragraph containing the data
        // returned form the server
        $('#some-div')
            .hide()
            .after('<p>' + data + '</p>');
});

假设 data 仅包含登录用户的用户名。

Use jQuery's post method:

$.post(
    '/url/to/post/login/details/to/',
    $('#login-form').serilaize(),
    function(data) {
        // hide the existing div and add a paragraph containing the data
        // returned form the server
        $('#some-div')
            .hide()
            .after('<p>' + data + '</p>');
});

assuming that data just contains the logged in users username.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文