javascript - 如何从一个html页面重定向到另一个html
问题描述
我创建了一个单页应用程序。基本上,我创建了一个接受用户输入并调用 Javascript 的 HTML 页面,该 Javascript 对休息服务进行 ajax 调用。返回响应后,我将数据附加到表中并在同一页面中显示结果。但现在我希望一页中的输入文本框和表格显示在另一页上。我怎样才能实现它?
我的 HTML 代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="index.js"></script>
<style>
.ApplicationName{
font-family: 'Times New Roman';
font-style: normal;
font-size:40px;
color: rgba(66,138,201,1);
height:38px;
width:auto;
font-weight: bold;
margin-left: 380px;
text-align:center;
}
table{
font-family:arial,sans-serif;
border-collapse: collapse;
width:100%
}
td,th{
border:1px solid #dddddd;
text-align: left;
padding: 20px;
}
#table {
margin-left: -850px;
}
</style>
</head>
<body>
<div class ="container" style="background-color: rgba(66,138,201,1)">
<div class ="navbar-header">
<p class="ApplicationName" style="color: white;">JIRA-STATUS TRACKER</p>
</div>
</div>
<br>
<div class="col-sm-4"></div>
<div class="row">
<div class="form-group col-sm-4">
<label for="name">Search by Manager</label>
<input type="managerid" class="form-control" id="ManagerId" type ="text" autocomplete="off" maxlength="8" onkeyup="alphanumOnly(this)" placeholder="ManagerId"></input>
<button id="submit" class="btn btn-primary" style="margin-top: 3px;" onclick="getReporteeList(); this.disabled = true;" >Submit</button></a>
<input type="reset" class="btn btn-primary" style="margin-top: 3px;" value="Reset" onClick="window.location.reload()"></input>
</div>
<br>
<div id ="table" style="display:none">
<div class="container text-center" >
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="panel panel-primary">
<div class="panel-heading" >Reportees List</div>
<table id = "employee_table" class="table table-hover" cellspacing="0" width="100%">
<tr>
<th>Number</th>
<th>Name</th>
<th>UserId</th>
<th>Count</th>
</tr>
</table>
</div>
</div>
<div id ="jiratable" style="display:none">
<div class="container text-center" >
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="panel panel-primary" style="width: 220%;">
<div class="panel-heading">JIRA - List</div>
<table class="table table-hover">
<table id = "Jira_table" class="table table-hover" cellspacing="0" style="width:220%;table-layout:fixed">
<thead>
<tr>
<th width="80">Number</th>
<th>JiraNumber</th>
<th>JiraStatus</th>
<th>EmailId</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
<html>
</html>
我的Javascript代码:
function getReporteeList() {
var name = document.getElementById('ManagerId').value;
var start = new Date().getTime();
console.log(start);
$.ajax({
url:'http://localhost:8088/JirasTrackingApp/reporter/
Reportees/ReporteeList/'+ $("#ManagerId").val(),
type:'GET',
"crossDomain": true,
dataType: 'json',
success: function(result){
var end = new Date().getTime();
var dur = end - start;
console.log("millisecs passed",dur);
var size = result.length;
var content = '';
var number = 1;
if(size>0){
document.getElementById('table').style.display="block";
$.each(result,function(key,value){
var num = number++;
content += '<tbody>';
content += '<tr>';
content += '<td>'+num+'</td>';
content += '<td>'+value.Name+'</td>';
content += '<td>'+value.UserId.toUpperCase()+'</td>';
content += '<td>'+'<a href="#" onclick ="getJira(\'' + value.UserId + '\')">'+value.count+'</a>'+'</td>';
content += '</tr>';
content += '<tbody>';
});
$('#employee_table').append(content);
}
....There is one more table jiratable in a similar way.
现在我将 2 个表格显示在一个页面中,但是如何在一页中显示输入字段。单击提交按钮后,它应该重定向到另一个页面以显示表格。请帮我解决这个问题。在此先感谢
解决方案
你需要这样的东西:
// Simulate a mouse click:
window.location.href = "http://www.w3schools.com";
// Simulate an HTTP redirect:
window.location.replace("http://www.w3schools.com");
推荐阅读
- reactjs - 为 API 授权 SPA
- hive - 如何从 hive 中的 Struct Array 中获取值
- python - 链表python中的检索函数
- python - 检查数据框中多列的最新值
- javascript - 无法在“DOMWindow”上执行“postMessage”
- android - 如何在某些设备上启用 enableShutterSound?
- pandas - 循环遍历 select 语句中的多个项目 - Pandas
- reactjs - 如何对历史回退功能设置条件?
- go - 从 rabbitmq 获取已发布消息的响应。戈朗
- javascript - AddEventListener 事件多次调用