2
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="html" uri="/struts-tags"%>
<!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">
<link type="text/css" href="css/login.css" rel="stylesheet">
<script type="text/javascript" src="jquery/jquery-1.7.2.js"></script>
<script type="text/javascript" src="jquery/jquery.dataTables.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.widget.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.dialog.js"></script>
<link type="text/css" href="css/jquery-ui-1.7.3.custom.css" rel="stylesheet">
<link type="text/css" href="css/jquery.dataTables_themeroller.css" rel="stylesheet">
<link type="text/css" href="css/jquery.dataTables.css" rel="stylesheet">
<link type="text/css" href="themes/base/jquery.ui.all.css" rel="stylesheet">
<style type="text/css">
    #grid_wrapper{
    width: 880px;margin:0 auto;
    margin-top: 100px;
    }
</style>
<script type="text/javascript">
$(document).ready(function(){
    $('#grid').dataTable({
         "bServerSide": true,
         "sAjaxSource": "companylist.action",
         "sPaginationType": "full_numbers",
         "bJQueryUI": true});

    $("#grid tbody").delegate("tr", "click", function() {
          var companyID = $("td:eq(1)", this).text();
          $("#companyID").val(companyID);
          $( "#passwordBox" ).dialog( "open" );
        });

    $("#passwordBox").dialog({
        autoOpen: false,
        modal: true,
    });

        $("#verifyPass").click(function(){
            $.ajax({
                url:"validatepassword.action",
                type:"POST",
                dataType:"JSON",
                data:{companyID:$("#companyID").val(),comPassword:$("#compassword").val()},
                success:function(response){
                    alert(response);
                }
            });
        });
    });
</script>
<title>Insert title here</title>
</head>
<body>
    <table id="grid" class="display">
        <thead>
            <tr>
                <th>Select</th>
                <th>Company ID</th>
                <th>Company Name</th>
                <th>Company Type</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
        <div id="passwordBox">
            <form id="passwordvali">
                <span id="error"></span>
                <input type="hidden" name="companyID" id="companyID">
                <label>Password:</label><br><br>
                <input type="password" name="compassword" id="compassword"/><br><br>
                <input type="submit" value="Verify" id="verifyPass"/>
            </form>
        </div>
    </table>
</body>
</html>

这段代码工作正常。它在 jQuery 数据表中显示公司数据网格。我为每家公司添加了一个单选按钮,每当用户选择一家公司时,都会打开一个对话框,提示输入公司的密码。

当我输入密码并单击“验证”按钮时,请求已成功发送,但浏览器在 url 中显示数据并给出错误。

4

0 回答 0