Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击,加载整个页面而不是表单_Javascript_Jquery_Ajax_Jsp - Fatal编程技术网

Javascript 单击,加载整个页面而不是表单

Javascript 单击,加载整个页面而不是表单,javascript,jquery,ajax,jsp,Javascript,Jquery,Ajax,Jsp,我有两个jsp页面,一个是index.jsp,另一个是rest.jsp 从index.jsp中单击Onclick函数时,将调用jquery函数来加载rest.jsp页面 相反,我希望加载rest.jsp中的表单,因为默认情况下,表单值为null,而不是我输入的值 这是我的index.jsp和rest.jsp 有人能帮我纠正一下吗? index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1"

我有两个jsp页面,一个是index.jsp,另一个是rest.jsp 从index.jsp中单击Onclick函数时,将调用jquery函数来加载rest.jsp页面

相反,我希望加载rest.jsp中的表单,因为默认情况下,表单值为null,而不是我输入的值

这是我的index.jsp和rest.jsp 有人能帮我纠正一下吗? index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Support Console</title>
<script src="http://code.jquery.com/jquery-1.4.min.js" type="text/javascript"></script>
<script>
function load_home(e){
 e.preventDefault();
  var con = document.getElementById('conte');
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function(e) {
     if(xhr.readyState == 4 && xhr.status == 200) {
     con.innerHTML = xhr.responseText;
     }
     }
 xhr.open("GET","restsim.jsp", true);
xhr.setRequestHeader('Content-type', 'script');
xhr.send();
 }
</script>
 <script>
function changeContent() {
    $('#main').load('restsim.jsp');
}

function change() {
    $('#main').load('check.jsp');
}
</script>
</head>
<style>
#top {
    background-image: url('footer-bg.jpg');
    background-color: black;
    background-repeat: no-repeat;
    width: 1240Px;
    background-position: bottom;
    height: 100px;
    z-index: -10;
}

#left {
    background-color: orange;
    width: 200Px;
    height: 800Px;
    float: left;
}

#main {
    background-color: #EEEEEE;
    width: 1040Px;
    height: 800Px;
    position: absolute;
    left: 200px; //
    top: 192Px; //
    padding: 20px;
    overflow-y: auto;
}
#sup {
    border: 1Px Solid green;
    border-radius: 20px;
    margin: 5Px;
}
.tab_h {
    text-align: center;
    color: white;
    font-family: verdana;
    cursor: default;
    font-size: 20Px;
}
.linkmenu {
    text-decoration: none;
    color: white;
    margin: 15Px;
    font-family: verdana;
}

.linkmenu:hover {
    background-color: green;
    border-radius: 5px;
}
</style>
<body style='padding: 0Px; margin: 0Px;'>
   <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="javascript">
function toggleVisibility(f) {
        document.getElementById('footer').style.opacity = f;
    }
        </script>
<div id=top>
        <center>
            <span style='color: white; font-size: 200%; font-family: verdana;'><br>Application</span>
        </center>
    </div>


<div class=tab_h>Application</div>
<div id ="conte">
<a href="#" onclick="changeContent()" class=linkmenu >Check User</a><br>
<a href="#" onclick="change()" class=linkmenu>Check Sim</a><br>
<br>
</div>
</div>
</body>

支撑控制台
功能加载(e){
e、 预防默认值();
var con=document.getElementById('conte');
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=函数(e){
如果(xhr.readyState==4&&xhr.status==200){
con.innerHTML=xhr.responseText;
}
}
open(“GET”,“restsim.jsp”,true);
setRequestHeader('Content-type','script');
xhr.send();
}
函数changeContent(){
$('#main').load('restsim.jsp');
}
函数更改(){
$('#main').load('check.jsp');
}
#顶{
背景图片:url('footer-bg.jpg');
背景色:黑色;
背景重复:无重复;
宽度:1240Px;
背景位置:底部;
高度:100px;
z指数:-10;
}
#左{
背景颜色:橙色;
宽度:200Px;
高度:800Px;
浮动:左;
}
#主要{
背景色:#EEEEEE;
宽度:1040Px;
高度:800Px;
位置:绝对位置;
左:200px//
顶部:192Px//
填充:20px;
溢出y:自动;
}
#苏普{
边框:1Px纯绿色;
边界半径:20px;
保证金:5Px;
}
.tab_h{
文本对齐:居中;
颜色:白色;
字体系列:verdana;
游标:默认值;
字体大小:20Px;
}
.linkmenu{
文字装饰:无;
颜色:白色;
利润率:15Px;
字体系列:verdana;
}
.link菜单:悬停{
背景颜色:绿色;
边界半径:5px;
}
功能切换可见性(f){
document.getElementById('footer').style.opacity=f;
}

应用 应用


rest.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Application</title>
<style>input { border:none;  }
body 
    {
    font-family:Verdana;
    }
</style>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
function xyz() {
    $('#get').load('rest.jsp');
}
</script>

</head>
<body>
    <div id="reset">
<span>Userid enter</span>
<br>Insert the user id:
<form id="get" name="get" onsubmit="return xyz(); return false;">
    <input type=hidden value=restsim.jsp name=page>
    <input type=hidden value=2 name=step> 
    <input style='border: 1Px solid black;' type=text name=userid><br>
    Or Email:<br>

    <input style='border: 1Px solid black;' type=text name=email> 
    <input value=go type=submit >

</form>
<%
        String userid = request.getParameter("userid");
        String email = request.getParameter("email");
        System.out.println("Userid::" + userid);
        int empty = 1;
        String query = null;

        if (userid != null && userid != ""){
            query = "select ssn,msisdn,status,product,owner from users.ui where owner="+userid+" or requestor="+userid+" order by product";
        }
        %>

    <%= request.getParameter("userid") %>
    <% 
        if (query != null ){
        ResultSet resultset = null;
        int cont = 0;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");

        } catch (ClassNotFoundException e) {
            System.out.println("Where is your Oracle JDBC Driver?");
            e.printStackTrace();
            return;

        }
        System.out.println("Oracle JDBC Driver Registered!");
        Connection connection = null;
        try{
            connection = DriverManager.getConnection(
                    "jdbc:oracle:thin:@hostname:sid:connectionname", "username",
                    "password");
        }
        catch (SQLException e) {
            System.out.println("Connection Failed! Check output console");
            e.printStackTrace();
            return;

        }
        if (connection != null) {
            System.out.println("You made it, take control your database now!");
            Statement statement = connection.createStatement() ;
            //resultset = statement.executeQuery("select  firstname , lastname from users where id = 9 ") ;
            System.out.println ("Query ::" + query);
                resultset = statement.executeQuery(query);
        } else {
            System.out.println("Failed to make connection!");
        }
    %>
    <% 
        int status = 0;
        String ssn = ""; 
        while(resultset.next()){
        cont++;
        ssn = resultset.getString(1);
        String msisdn = resultset.getString(2);
        status = resultset.getInt(3);
        if (ssn != "" && ssn != null && msisdn != "" && msisdn != null){
            empty = 0;
        }   
    %>
        <table border=1><tr><td colspan=6 style=background-color:orange><b><i>USER DATA:</i></b></td></tr>
            <tr><td style=background-color:green;color:white;><b>USER ID</b></td>
                </b></td></tr>
            <tr>
                <td><%=userid %></td>
                <td><%= resultset.getString(5) %></td>
                <td><a href="check.jsp&step=2&phonenumber=<%=phone%>"><%=phone%></a></td>
                <td><a href="check.jsp&step=1&number=<%=number%>&number=<%=number%>"><%=number%></a></td>
                <td><%=status %></td>
                <td><%=resultset.getString(4) %></td>
            </tr>
    <% } 
        if (cont == 0) {%>
            <tr><b><i>There are no rows for this query.</i></b></tr>
    <% } 
        if (status != 2 | ssn != ""){

        }
     }%>
</div>
</body>
</html>

应用
输入{边框:无;}
身体
{
字体系列:Verdana;
}
函数xyz(){
$('#get').load('rest.jsp');
}
用户ID输入

插入用户id:
或电子邮件:
用户数据: 用户ID 此查询没有行。
在单独的脚本标记中创建函数,并对表单进行如下更改

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
    function xyz() {
        $('#get').load('rest.jsp');
    }
</script>

    <form id="get" name="get" onsubmit="xyz(); return false;">

函数xyz(){
$('#get').load('rest.jsp');
}

@bhari确保路径正确。检查控制台以查看任何可能的错误。@Rejith R Krishnan在创建单独的scrip let标记时,表单本身正在加载,而不是从表单中获取输入的用户ID。当在input.jsp页面中单击Check user的onclick时,表单正在加载,但默认情况下显示空值,但是我想展示这个桌子..怎么办