everything goes well in a regular HTML page, but with the same code used in a liferay portlet,I have this problem:
GET http://localhost:8080/web/guest/data/myfile.json 404 (Not Found) index.js:103
This is the code:
function loadFiles(){
loadJSONNetworkInventory(function(response) {
parsedMyFile = JSON.parse(response);
});
}
function loadJSONNetworkInventory(callback) {
var xobjNI = new XMLHttpRequest();
xobjNI.overrideMimeType("application/json");
xobjNI.open('GET', 'data/myfile.json', false);
xobjNI.onreadystatechange = function () {
if (xobjNI.readyState == 4 && xobjNI.status == "200") {
callback(xobjNI.responseText);
}
};
xobjNI.send(null);
}
<%=request.getContextPath()%>/data/myfile.json
? – SASMdata
folder at the root of your portlet, place yourJSON
file there then use this path/data/myfile.json
. – Parkash Kumarhttp://localhost:8080/your-portlet/data/myfile.json
– Parkash Kumar