掲示板

Load JSP page using jQuery("#div").load()

13年前 に Ng SG によって更新されました。

Load JSP page using jQuery("#div").load()

Junior Member 投稿: 27 参加年月日: 10/04/16 最新の投稿
Hi,

I would like to ask is there possible to load jsp page
in custom portlet(sdk environment) which i have used following
code:



<script type="text/javascript">
Liferay.bind(
        'updating',
        function(event) 
        {
          	alert("changes");
        	document.getElementById("contentList").innerHTML = "";
	        jQuery("#contentList").load('contentList.jsp');
        }
     );
</script>

<form>
		<div id="contentList">
		</div>
	</form>



However, liferay unable to detect the existence of 'contentList.jsp' which i have created in same directory with view.jsp. Anyway for me to load that particular 'contentList.jsp' into the div?

Thanks and best regards,
NG
thumbnail
13年前 に Patrick Koppers によって更新されました。

RE: Load JSP page using jQuery("#div").load()

New Member 投稿: 4 参加年月日: 10/06/18 最新の投稿
I don't know if it will work, but can try this:

jQuery("#contentList").load('&lt;%= request.getContextPath() %&gt;/path/contentList.jsp');


where "path" is your path to the .jsp from the portlet root-directory. So, if your .jsp-file lies directly in the portlet root-folder, is is just "/contentList.jsp".
thumbnail
6年前 に Maria Prasad によって更新されました。

RE: Load JSP page using jQuery("#div").load()

New Member 投稿: 1 参加年月日: 17/05/09 最新の投稿
The jQuery Load method will work on all type so pages including jsp. You may be missing the MIME Mappings in web server so include them for jsp page too. From the definition of jQuery Load method, the code to load the contents of your jsp page would simply be:
$("#contentList").load("contentList.jsp");


If you want to load just a particular div content from the jsp page the jQuery Load code will be:
$("#contentList").load("contentList.jsp #particularDiv");


Thank You.
6年前 に Matthew K. によって更新されました。

RE: Load JSP page using jQuery("#div").load()

Junior Member 投稿: 74 参加年月日: 15/08/31 最新の投稿
No, this won't work.
You have to use the resource phase of the portlet. So just implement everything in the serveResponse method and deliver your jsp file.
In your javascript code you have to replace "contentList.jsp" with the resource url then.