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();
Comments
Post a Comment