基本资料图来自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/