<?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>Get the AJAX parameters on the server</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=47331975" />
  <subtitle>Get the AJAX parameters on the server</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=47331975</id>
  <updated>2026-06-27T02:18:56Z</updated>
  <dc:date>2026-06-27T02:18:56Z</dc:date>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47451938" />
    <author>
      <name>Prakash Khanchandani</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47451938</id>
    <updated>2015-01-08T14:17:18Z</updated>
    <published>2015-01-08T14:17:18Z</published>
    <summary type="html">&lt;blockquote&gt;I&amp;#39;m also of the impression that LR has a vibrant community here in the forums&lt;/blockquote&gt;&lt;br /&gt;Strongly agree.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;so there is no need to post to SO unless you have a non-Liferay question. I know people want the &amp;#39;point count&amp;#39; thing for posting questions and answers, and I also know that their interface may be favored over Liferay&amp;#39;s, but at the end of the day the Liferay expertise is over here, not over there.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Not so much in agreement here. More than the point-count the interface is too good to beat, sleak and its clean - just questions and good-answers unlike hijacking discussions in forum questions (like i am doing here &lt;img alt="emoticon" src="@theme_images_path@/emoticons/tongue.gif" &gt;). Good features for moderation, can clean-up questions and answers for future visitors.&lt;br /&gt;&lt;br /&gt;Liferay expertise is comparatively less but its building up, infact many liferay-staff are members. SO may not be first place, but definitely the second best to get an answer on liferay.&lt;br /&gt;&lt;br /&gt;Anyways, thank you so much David for giving your valuable time and support to us.</summary>
    <dc:creator>Prakash Khanchandani</dc:creator>
    <dc:date>2015-01-08T14:17:18Z</dc:date>
  </entry>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47398900" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47398900</id>
    <updated>2015-01-07T13:16:33Z</updated>
    <published>2015-01-07T13:16:33Z</published>
    <summary type="html">I don&amp;#39;t monitor SO much at all.  I have little if any interest in building a &amp;#39;point count&amp;#39; in answering questions.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m also of the impression that LR has a vibrant community here in the forums, so there is no need to post to SO unless you have a non-Liferay question.  I know people want the &amp;#39;point count&amp;#39; thing for posting questions and answers, and I also know that their interface may be favored over Liferay&amp;#39;s, but at the end of the day the Liferay expertise is over here, not over there.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2015-01-07T13:16:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47381262" />
    <author>
      <name>Eloy Fernández</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47381262</id>
    <updated>2015-01-07T08:27:37Z</updated>
    <published>2015-01-07T08:27:37Z</published>
    <summary type="html">OK!! I was thinking do it, but I thought that link form a different forum wasn´t a good idea. Next time, I´ll do. &lt;br /&gt;Thanks Prakash.</summary>
    <dc:creator>Eloy Fernández</dc:creator>
    <dc:date>2015-01-07T08:27:37Z</dc:date>
  </entry>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47379844" />
    <author>
      <name>Prakash Khanchandani</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47379844</id>
    <updated>2015-01-07T06:00:34Z</updated>
    <published>2015-01-07T06:00:34Z</published>
    <summary type="html">Ah! Cross-posting on different sites. When you cross-post a question on multiple sites please link the question to each other it helps the community.&lt;br /&gt;&lt;br /&gt;Thanks for putting the answer though and also as usual David had already answered it before it was done on Stackoverflow.</summary>
    <dc:creator>Prakash Khanchandani</dc:creator>
    <dc:date>2015-01-07T06:00:34Z</dc:date>
  </entry>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47354539" />
    <author>
      <name>Eloy Fernández</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47354539</id>
    <updated>2015-01-06T13:53:54Z</updated>
    <published>2015-01-06T13:53:54Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Yes... thank you. It was the namespacing, I sove it making this:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
jQuery.ajax({
	url:url,
	type:'POST',
	dataType: "json",
	data:{"&amp;lt;portlet:namespace /&amp;gt;operators" : operators},
	success: function(data)
	{
		jQuery('#result').html(data.result);
	}
});
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Thank you.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Eloy Fernández</dc:creator>
    <dc:date>2015-01-06T13:53:54Z</dc:date>
  </entry>
  <entry>
    <title>RE: Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47336242" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47336242</id>
    <updated>2015-01-06T01:58:10Z</updated>
    <published>2015-01-06T01:58:10Z</published>
    <summary type="html">If I had to guess I would put my money on namespacing issues...&lt;br /&gt;&lt;br /&gt;Namespacing occurs on both the client side as well as on the server side.  When an incoming parameter is namespaced correctly, Liferay will include it to pass along to the portlet request.  Any parameter not namespaced correctly is not included in the portlet request as it is likely for some other portlet or purpose.&lt;br /&gt;&lt;br /&gt;So I&amp;#39;m guessing that the &amp;#34;operators&amp;#34; guy is there on the HTTP request, but it gets dropped on it&amp;#39;s way into the portlet as part of the ResourceRequest.&lt;br /&gt;&lt;br /&gt;I&amp;#39;d suggest using PortalUtil.getHttpServletRequest(resourceRequest) to get the incoming http request, then look for the &amp;#34;operators&amp;#34; parameter there.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2015-01-06T01:58:10Z</dc:date>
  </entry>
  <entry>
    <title>Get the AJAX parameters on the server</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47331974" />
    <author>
      <name>Eloy Fernández</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=47331974</id>
    <updated>2015-01-06T01:03:25Z</updated>
    <published>2015-01-06T01:03:25Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hello everybody.&lt;br&gt;&lt;br&gt;I am trying to send an AJAX request to a portlet, and it half works. I show you my code and after explain better:&lt;br&gt;&lt;br&gt;The jQuery AJAX:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
jQuery("#operation").click(function() 
{
    var url         = '&amp;lt;portlet:resourceurl id="getDataResourceURL"&amp;gt;&amp;lt;/portlet:resourceurl&amp;gt;';
    var operators   = jQuery('#result').html();
    jQuery.ajax({
        url:url,
        type:'post',
        dataType: "json",
        data:{operators:operators},
        success: function(data)
        {
            jQuery('#result').html(data.result);
        }
});
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;And the serveResource&lt;br&gt;&lt;pre&gt;&lt;code&gt;
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException 
{
    String resourceId = resourceRequest.getResourceID();
    if (Validator.isNotNull(resourceId) &amp;amp;amp;&amp;amp;amp; resourceId.length() != 0 &amp;amp;amp;&amp;amp;amp; resourceId.equalsIgnoreCase("getDataResourceURL"))
    {
        //final String operators = resourceRequest.getParameter("operators");
        String operators = ParamUtil.getString(resourceRequest, "operators");

        _log.info("The data from AJAX are: " + operators);

        JSONObject jsonFeed = JSONFactoryUtil.createJSONObject();


        jsonFeed.put("result", 8);
        resourceResponse.setContentType("application/json");
        resourceResponse.setCharacterEncoding("UTF-8");
        resourceResponse.getWriter().write(jsonFeed.toString());
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;OK!! What it is working is the response, when I press the input with the id operation the div with id result loads an 8 (that the server response writting on jsonFeed.put("result", 8); The 8 is only for a test). What it is not working is the operators String on _log.info("The data from AJAX are: " + operators); that it is a null (if I use resourceRequest.getParameter("operators");) or an empty string (if I use ParamUtil.getString(resourceRequest, "operators");).&lt;br&gt;&lt;br&gt;What am I doing wrong? and what can I do to receive this value?&lt;br&gt;&lt;br&gt;Thank you very much.&lt;br&gt;&lt;br&gt;PS: On the client side, I tried too this:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
jQuery.getJSON(url, {operators:operators}, function(data) 
{
    jQuery('#result').html(data.result);
});
&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Eloy Fernández</dc:creator>
    <dc:date>2015-01-06T01:03:25Z</dc:date>
  </entry>
</feed>
