2013-05-31 68 views
2

基本配置文件视图来自index.cs.asp?Process=ViewB_Profile
当用户点击<a href="index.cs.asp?Process=EditB_Profile">edit profile</a>时,将打开对话框来编辑基本配置文件。
但我想编辑窗体来替换基本的配置文件视图数据。
我该怎么做,有没有插件?用编辑表格替换查看数据

非常感谢!

编辑!

<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('.'); 
      } 
     }); 
    }); 
    }); 

回答

0

这将是相当琐碎切换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> 
+0

我想过使用太多,但ID来拉来自外部网址... – Efe

+0

这很好。只需在AJAX成功处理程序中填充表单html,然后切换配置文件数据div和表单。 – landons

+0

你可以请检查现在编辑的代码,会工作吗? – Efe