我正在尝试在我的页面中包含另一个页面(“EHSiteHeadHome.jsp”)(“AddExceptionAssetID.jsp”)。我还想在我的页面中包含自动提示。如果我不包括其他页面但是与其他页面一起使用,则自动提示工作正常,它无法正常工作。实际上,jsp:include。
没有发生Ajax调用AddExceptionAssetID.jsp
foreach ($remote_user_detail as $value){
$user = User::where('unique_id',$value->userid)->first();
if(count($user) > 0){
$user->unique_id = $value->userid;
$user->user_first_name = $value->name;
$user->card_id = $value->cardnumber;
$user->save();
}else{
$user = new User();
$user->company_id = Auth::user()->company_id;
$user->user_label = 2;
$user->unique_id = $value->userid;
$user->user_first_name = ($value->name=='') ? '' : $value->name ;
$user->card_id = $value->cardnumber;
$user->save();
}
}
EHSiteHeadHome.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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Add Exception</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" >
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$(function() {
$("#AssetID").autocomplete({
source: function(request, response) {
$.ajax({
url: "AssetAutocomplete",
type: "GET",
data: {
term: request.term
},
dataType: "json",
success: function(data) {
response(data);
}
});
}
});
});
});
</script>
</head>
<body>
<%-- <jsp:include page="EHSiteHeadHome.jsp" /> --%>
<%-- this is where I am facing problem
--%>
<div class="module mx-auto my-auto" style="margin:20px 10px 10px 20px">
<div class="container" style="margin-top:180px">
<span id="ErrorMsg" style="margin-left:100px;color:red;font-weight:bold;">${msg}
</span>
<form class="form" action="AddException" method="post">
<div class="form-group row">
<label for="AssetID" class="col-sm-2 col-form-label col-form-label-sm"> Asset ID: </label>
<input type="text" style="width:150px;" class="form-control col-sm-4 form-control-sm col-form-label-sm" id="AssetID" name="AssetID" onkeyup="showData(this.value);">
</div>
<input type="submit" value="CheckAsset" class="btn btn-primary btn-sm" name="AddException" >
</form>
</div>
</div>
</body>
</html>
AjaxAutocomplete.java
<%@ 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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Site Head</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<style>
body {
font-family: "Lato", sans-serif;
}
.navbar-light .navbar-nav .nav-link {
color: #fff; font-weight: 100px;
}
.navbar-nav .nav-link {
color: #fff;
}
.btco-menu li > a {
padding: 10px 15px;
color: #000;
}
.btco-menu .active a:focus,
.btco-menu li a:focus ,
.navbar > .show > a:focus{
background: transparent;
outline: 0;
background-color: darkgray;
}
.dropdown-menu .show > .dropdown-toggle::after{
transform: rotate(-90deg);
}
i{
margin: 0 20px 0 0;
}
</style>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar fixed-top navbar-expand-sm navbar-toggleable-md bg-dark navbar-light text-white btco-menu " style="background-color: #696969;color: white; ">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="EHSiteHeadHome.jsp">
<img src="img/Brand.PNG" style=" height: 50px; width: 80px;border-radius: 15%;">
</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item ">
<!-- <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> -->
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="https://bootstrapthemes.co" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-bars"> Menu</i> </a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item dropdown-toggle" href="#"><i class="far fa-handshake" style="margin: 0 13px 0 0;"></i> Exception</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item " href="AddExceptionAssetID.jsp"> <i class="fas fa-user-plus" style="margin: 0 5px 0 0;"></i> Add</a></li>
<li><a class="dropdown-item " href="UpdateException.jsp"> <i class="fas fa-edit" style="margin: 0 5px 0 0;"></i> Update</a></li>
<li><a class="dropdown-item " href="RemoveException.jsp"> <i class="fas fa-trash" style="margin: 0 15px 0 0;"></i>Remove</a></li>
<li><a class="dropdown-item " href="DownloadException.jsp"> <i class="fa fa-download" style="margin: 0 15px 0 0;"></i>Download Evidence</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#"><i class="fas fa-book" style="margin: 0 13px 0 0;"></i> Reports</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item " href="ReportExceptionSiteHead.jsp"> <i class="far fa-check-circle" style="margin: 0 10px 0 0;"></i> View All Records</a></li>
<li><a class="dropdown-item " href="ReportExceptionSiteHeadFiltered.jsp"> <i class="far fa-check-circle" style="margin: 0 10px 0 0;"></i> View Filetered Reports</a></li>
</ul>
<!-- </li>
<li><a class="dropdown-item " href="#"> <i class="fas fa-wrench" style="margin: 0 10px 0 0;"></i> Add Metadata </a>
</li> -->
</ul>
</li>
</ul>
<ul class="navbar-nav ml-auto" style="float:right;">
<li class="nav-item">
<p class="nav-link" href="#" style="padding-right: 20px"><i class="fas fa-user-circle">Site Head    <%= session.getAttribute("activeUser") %> </i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="Logout.jsp" style="padding-right: 20px"><i class="fas fa-power-off"></i> </a>
</li>
<!--<li class="nav-item"><a href="#">User</a>
<li class="nav-item"><a href="#">Logout</a>-->
</ul>
</div>
</nav>
<script>
$( document ).ready( function () {
$( '.navbar a.dropdown-toggle' ).on( 'click', function ( e ) {
var $el = $( this );
var $parent = $( this ).offsetParent( ".dropdown-menu" );
$( this ).parent( "li" ).toggleClass( 'show' );
if ( !$parent.parent().hasClass( 'navbar-nav' ) ) {
$el.next().css( { "top": $el[0].offsetTop, "left": $parent.outerWidth() - 4 } );
}
$( '.navbar-nav li.show' ).not( $( this ).parents( "li" ) ).removeClass( "show" );
return false;
} );
} );
</script>
<span id="ErrorMsg" style="margin-left:100px;color:red;font-weight:bold;">${msg}
</span>
</body>
</html>
AjaxAutocomplete.java是ajax请求数据的java servlet