<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>ajax call to serve resource..</title>
  <link rel="self" href="https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=41608681" />
  <subtitle>ajax call to serve resource..</subtitle>
  <id>https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=41608681</id>
  <updated>2026-10-15T12:00:21Z</updated>
  <dc:date>2026-10-15T12:00:21Z</dc:date>
  <entry>
    <title>RE: ajax call to serve resource..</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110759583" />
    <author>
      <name>N. Belo</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110759583</id>
    <updated>2018-08-22T09:21:40Z</updated>
    <published>2018-08-22T09:21:40Z</published>
    <summary type="html">&lt;p&gt;Well I think it's possible to make an Ajax Call from the Theme if you
  have defined a Friendly URL for a portlet and then do a POST or GET to
  that URL.&lt;br /&gt; Don't you agree?&lt;/p&gt;</summary>
    <dc:creator>N. Belo</dc:creator>
    <dc:date>2018-08-22T09:21:40Z</dc:date>
  </entry>
  <entry>
    <title>RE: ajax call to serve resource..</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41614836" />
    <author>
      <name>Mohammad Danish</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41614836</id>
    <updated>2014-08-19T12:16:00Z</updated>
    <published>2014-08-19T12:16:00Z</published>
    <summary type="html">As far as I know you cant make ajax call from theme. To make ajax calls you need to have a portlet in your theme. &lt;br /&gt;Make your ajax call from portlet, and embed it into portal theme.</summary>
    <dc:creator>Mohammad Danish</dc:creator>
    <dc:date>2014-08-19T12:16:00Z</dc:date>
  </entry>
  <entry>
    <title>RE: ajax call to serve resource..</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41611998" />
    <author>
      <name>Pankaj Kathiriya</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41611998</id>
    <updated>2014-08-19T12:02:38Z</updated>
    <published>2014-08-19T12:02:38Z</published>
    <summary type="html">If you are asking about calling your portlet&amp;#39;s serveResource method outside of your portlet, then use &amp;lt;liferay-portlet:resourceURL/&amp;gt; (using taglib uri &amp;#34;http://liferay.com/tld/portlet&amp;#34;)&lt;br /&gt;&lt;br /&gt;For example: &amp;lt;liferay-portlet:resourceURL portletName=&amp;#34;NAMEOFPORTLET&amp;#34; var=&amp;#34;addUrl&amp;#34;/&amp;gt;</summary>
    <dc:creator>Pankaj Kathiriya</dc:creator>
    <dc:date>2014-08-19T12:02:38Z</dc:date>
  </entry>
  <entry>
    <title>ajax call to serve resource..</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41608680" />
    <author>
      <name>Lucian Alexandrescu</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=41608680</id>
    <updated>2014-08-19T09:28:45Z</updated>
    <published>2014-08-19T09:28:45Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi everyone!&lt;br&gt;&lt;br&gt;I make this call from view.jsp and is working perfect..&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;portlet:resourceurl id="addEntry" var="addUrl" /&amp;gt;

&amp;lt;input type="button" value="Add Ajax Call" onclick="ajaxAddEntry('${addUrl}');"&amp;gt;

function ajaxAddEntry(addUrl) {	
		
	jQuery.ajax({
 			type: 'GET',
			 url:  addUrl,
			 cache:false,
			 async:true,
			 error: function(){
						 alert('error');
				    },		
			dataType: "text",
			data :{
				data1: "123",
				data2: "456",				
 				},
 			success: function(status) {			
				 alert('response : ' + status);
			 }
		});
}



public class MyPortlet extends MVCPortlet {	

    @Override
    public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
    		throws PortletException {        	
    	
		 try {
			 String resourceID = resourceRequest.getResourceID();

			 if (resourceID.equals("addEntry")) {
				
				System.out.println("here test addEntry");
				
				addEntry(resourceRequest, resourceResponse);
			}
...

}


public JSONObject addEntry(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
			throws Exception {

          String data1 = resourceRequest.getParameter("bookmarkUrl");

}



&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;How can I achieve the same result calling the method from portal theme? &lt;br&gt;&lt;br&gt;Thanks in advance for any suggestion!&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Lucian Alexandrescu</dc:creator>
    <dc:date>2014-08-19T09:28:45Z</dc:date>
  </entry>
</feed>
