Suppose you want to get your context path in JS/JQuery on clicking an Button like, In JSP/HTML:- <input type="button" id="myButton"> In JQuery :- $('# myButton ').click(function() { console.log( myC ontextPath ); }); Then you can pass values to JS/JQuery as, <input type="button" id="myButton" myContextPath="${pageContext.request.contextPath}"> Then in JS/JQuery you can write as, $('# myButton ').click(function() { var myC ontextPath = $(this).attr(' myC ontextPath '); console.log( myC ontextPath ); });
There are lot of solutions present on Liferay forum, stackoverflow and many more can be found on google but all are very difficult, not clear and also not working.... So I found a simple solution which is working and I am sharing it with you people, and hope you will find it helpful!!! You just have to add below line to each AJAX call success at client side (in JavaScipt / JQuery / AngularJS). Liferay.Session.extend();
By adding below lines in JSP page we can achive this: <% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response.setHeader("Pragma","no-cache"); //HTTP 1.0 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server %> Other solution is by adding below lines in <head></head> of your JSP page: <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT">
Comments
Post a Comment