I am developing Liferay portlet. The portlet should load xml file from same server as Liferay and then via ajax parse this xml and pass these values to jQuery. I started with html file to test the functionality only. So far everything works but when I put html and js code to portlet then jQuery works but I cannot load file. I would like to have xml file located at /etc/config_files/settings.xml
Here is part of jQuery my script
function getToolContent(tool){
var layer = '.links_' + tool.toLowerCase();
$(layer).text("");
$.ajax({
type:"GET",
url: "/etc/config_files/settings.xml",
dataType: "xml",
success: function(xml){
$(xml).find("tool").each(function() {
if($(this).find('section').text() == tool){
var title = $(this).find('title').text();
var text = $(this).find('text').text();
$(this).find("link").each(function() {
var label = $(this).find('label').text();
var referer = $(this).find('referer').text();
$(layer).append('<a href="' + referer + '" class="formatted_link" alt="'+ tool + ' link">'+ label +'</a><br>');
});
$("#text").html('<h2>'+ title + '</h2>' +'\n'+ text);
}
});
}
});
}
and here is sample of xml file
<?xml version="1.0" encoding="UTF-8"?>
<descriptions>
<tool>
<section>TOOL NAME</section>
<title>TOOL TITLE</title>
<text>
<![CDATA[
<ul>
<li>FEATURE 1</li>
<li>FEATURE 2</li>
<li>FEATURE 3</li>
</ul>
]]>
</text>
<links>
<link>
<label>TOOL LINK LABEL 1</label>
<referer>https://mytool1.com/</referer>
</link>
<link>
<label>TOOL LINK LABEL 2</label>
<referer>https://mytool2.com/</referer>
</link>
</links>
</tool>
<tool>
...
</tool>
</descriptions>
Simply I cannot get data from settings.xml
-Thanks for help
in case that I have xml inside portlet then this helped:
settings.xml is in $PORTLET-DIR/docroot/js/
I the second case when I tried to load xml anywhere from server
I get this eclipse error message
I would like to be able to read the xml from the same server as Liferay or, if it is possible, read it from different server
Thanks