HTML:
<table border="1">
<tr id="main_account">
<td width="50%">
<h3 style="margin-left:10px">Details</h3>
<table width="270">
<tr>
<td>First name:</td>
<td><input type="text" name="first_name" id="id_first_name" /></td>
</tr>
<tr>
<td>Last name:</td>
<td><input type="text" name="last_name" id="id_last_name" /></td>
</tr>
<!-- other html -->
</table>
</td>
</tr>
<tr id="authorised_reporter">
<td width="100%" colspan="2">
<form method="post" action="." id="reporter-form">
<table width="100%">
<tr>
<td style="width:100px;">First name:</td>
<td><input type="text" name="first_name" id="id_first_name" /> </td>
</tr>
<tr>
<td>Last name:</td>
<td><input type="text" name="last_name" id="id_last_name" /> </td>
</tr>
<tr>
<td>Daytime phone:</td>
<td><input id="id_phone_daytime" type="text" class="trim-space" name="phone_daytime" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
显示页面加载 id #main_account 并隐藏 id #authorised_reporter。如果单击 #authorised_reporter #authorised_reporter 处于显示 block 中并且#main_account 处于不显示状态。在#authorised_reporter 选项卡中,我正在使用 ajax 更新用户数据,成功调用后我正在重新加载页面。由于 onload 我在重新加载后默认显示#main_acount 它将我带到#main_account 但我需要的是在 pagereload 成功调用 ajax 之后页面应该显示#authorised_reporter 选项卡而不是#main_account 选项卡.
我尝试了以下但没有用,带我到#main_account
//other code not shown
success: function() {
location.reload();
$('#authorised_reporter').css("display", "block");
$('#main_account').css("display", "none");
$("#sucess").show();
$("#sucess").text("Changes has been updated.");
}
最佳答案
您的更改可能不适用,因为,
location.reload();
它会重新加载内容,成功功能的后面部分将不会生效。如果你能更具体并提供更多的html,就能给你答案。您也可以在 jQuery 中使用 .done()。
关于javascript - 在 ajax 调用后重新加载相同的 tr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18913904/