I have a webservice developed in Java that is responsible for returning all the compositions of a particular fabric / piece (textile area).
you must first obtain the current drawing and then the remaining ones. So far there is no problem.
The part I tried to explain explains belongs to the backend . The problem lies in the frontend , more specifically on the page that is responsible for updating an article. An article can be described as a product, which has already been designed, and / or planned and which is in catalog. Faced with this, as I said earlier, I have to previously show the values of the attributes of an article. Note that the article with ref "UL ..."
already has some values filled in:
Theproblemoccurs,asIsaid,themomentItrytogetthecomposition.IshowbelowthecodethatItriedtoimplementandthatiscausingproblems:
functionpopulate(frm,data){varout="";
for (var key in data) {
if(key == "composicao")
{
out=encodeURI(data[key]);
var uri="http://127.0.0.1:8080/revistaSystem/resplaneamento/ServicoComposicao/ObterTodasAsComposicoes/";
var urifinal = uri.concat(out);
alert(urifinal);
$.ajax({
url:urifinal,
complete: function (response) {
var data=response.responseText;
alert(data);
var jsonData = $.parseJSON(data);
var $select = $('#composicao');
$select.empty();
$(jsonData).each(function (index, o) {
var $option = $("<option/>").attr("value", o.numPK).text(o.composicao);
$select.append($option);
});
//preencher option
},
error: function () {
$('#output').html('Bummer: there was an 1error!');
},
});
}
}
Faced with this, in the case of a particular composition, there is a need to encode the parameter (the string that enters as a parameter), since a composition, of a given fabric, can be simple or composite , that is:
Because an article can have a composite composition, it is always separated by a "/"
. Here's the problem. The webservice always takes a JSON to be interpreted through JavaScript / AJAX, but on the side of the frontend I can not get JSON, I'm just getting the following message error):
Valuetakenupbywebservice:
How can I solve this problem?