liferay 调用ajax
生活随笔
收集整理的這篇文章主要介紹了
liferay 调用ajax
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1 首先是view.jsp代碼?
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> <%@page contentType="text/html; charset=UTF-8" %> <portlet:defineObjects /><%String rootPath = renderRequest.getContextPath(); %> <script type="text/javascript" src="<%=rootPath%>/js/jQuery/jquery-2.1.1.js"></script>This is the <b>Ajax Learn</b> portlet in View mode.<portlet:resourceURL var="ajaxUrl1" id="test1"/> <portlet:resourceURL var="ajaxUrl2" id="test2"/><script type="text/javascript">function ajaxTest(){$.post('<%=ajaxUrl1%>',{p_p_resource_id:'test1'},function(data){$('#message').html(data);})}function ajaxTest2(){$.post('<%=ajaxUrl2%>',function(data){$('#message').html(data);})} </script><div>這是Ajax測(cè)試,從點(diǎn)擊下面的按鈕從服務(wù)端獲取數(shù)據(jù)。</br><input type="button" value="ajax請(qǐng)求1" οnclick="ajaxTest();"><input type="button" value="ajax請(qǐng)求2" οnclick="ajaxTest2();"><div id="message"></div> </div>
3 點(diǎn)擊之前的view.jsp頁(yè)面
4 點(diǎn)擊ajax請(qǐng)求1后的頁(yè)面
總結(jié)
以上是生活随笔為你收集整理的liferay 调用ajax的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: liferay 如何添加css或者js
- 下一篇: liferay 定时调度器用法