In one JSP file I have an element:
<div id="mydialog"></div>
I have an anchor tag <a href='#' id="#newentry">
On the click of the anchor tag I have some jQuery events to open a dialog and load in a p tag into the dialog:
jQuery.noConflict();
var $ = jQuery;
var myDialog;
jQuery(document).ready(function(){
operation = "addEntryPage";
document.forms[0].selectedUserdataIndex.value = "";
document.forms[0].search.value = "";
myDialog = jQuery('#mydialog').dialog({
autoOpen: false,
modal: true,
width: 200,
height: 200
});
jQuery('#newentry').click(function(e){
e.preventDefault();
myDialog.load('/console/admin/NewFile.jsp #p').dialog("open");
return false;
});
});
I'm trying to load the p tag from NewFile.jsp into my dialog div. Here is NewFile.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p>Sample text.</p>
</body>
</html>
The dialog opens but the sample text does not appear inside. In the developer tools I'm seeing a 200 response code from the load() GET and the preview shows the sample text. Any ideas?
Edit:
Changed NewFile.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p id="target">Sample text.</p>
</body>
</html>
and:
myDialog.load('/console/admin/NewFile.jsp #target').dialog("open");
#p
is looking for aid="p"
element. You only have ap
. Either you need to add theid
, or change the selector to...NewFile.jsp p
a
is clicked<a href='#' id="#newentry">
👈 perhaps you want the ID to benewentry
instead of#newentry