javascript - 用编辑表单替换 View 数据

标签 javascript jquery

基本资料图来自index.cs.asp?Process=ViewB_Profile .
当用户点击 <a href="index.cs.asp?Process=EditB_Profile">edit profile</a> , 对话框打开以编辑基本配置文件。
但是我想要编辑表单来替换基本的个人资料 View 数据。
我该怎么做,有插件吗?

非常感谢!

已编辑!

<script type="text/javascript">
$(document).ready(function() { 
    $(function V_Basic_Profile() {
        $.ajax({
            type: "GET",
            url: "content/profile/index.cs.asp?Process=ViewB_Profile",
            success: function(data) {
                $("#B_Profile").append(data);
            },
            error: function (data) {
                $("#B_Profile").append('.');
            }
        });
    });
    $(function E_Basic_Profile() {
        $.ajax({
            type: "GET",
            url: "content/profile/index.cs.asp?Process=ViewB_Profile",
            success: function(data) {
                $("#B_Profile").append(data);
            },
            error: function (data) {
                $("#B_Profile").append('.');
            }
        });
    });
    });

最佳答案

在 jQuery 中切换两个不同的 div 是相当简单的:

<div id="profile">
...
</div>
<form id="profileForm">
...
</form>

<script>
// ...
success: {
    $('#profileForm').html(data).show();
    $('#profile').hide();
}
// ...
</script>

编辑:试试这个

<div id="profile_view">Loading...</div>
<div id="profile_form" style="display:none; ">Loading...</div>

<a href="javascript:loadProfileForm()">Edit Profile</a>

<script>
function loadProfileView()
{
    $.get("content/profile/index.cs.asp?Process=ViewB_Profile", function(html) {
        $('#profile_view').html(html).show();
        $('#profile_form').hide();
    });
}
function loadProfileForm()
{
    $.get("content/profile/index.cs.asp?Process=EditB_Profile", function(html) {
        $('#profile_form').html(html).show();
        $('#profile_view').hide();
    });
}
$(loadProfileView);
</script>

关于javascript - 用编辑表单替换 View 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16863185/

相关文章:

javascript - 如何修复 javascript 和 c# 上发生的计算错误

javascript - 小于或等于条件在我的脚本中不起作用

javascript - =_= 在 JavaScript 或 HTML 中是什么意思?

php - 如何在 php、mysql 和 ajax session 中显示用户在线或离线

javascript - Bootstrap 文本框自动完成

Javascript:对象如何存储对另一个对象方法的引用,并将其称为 "remotely"?

javascript - 如何使用 Prototype 在 IE8 中旋转图像?

javascript - jquery : detecting scroll position

jquery - 如何将模糊事件绑定(bind)到实时点击事件?

javascript - 使用 jquery/javascript 设置多个 img alt 监听器