I'm trying to get the result of a request to an API (json), and send it to another function that will write to the localstorage, I even got the value of the product, but with the name that is string no is working, I have tried to trim (), substr () and nothing changes the value of the variable where the json data is returned.
Code below:
function openModalquantidade(key){
$.getJSON("http://www.outletclube.com/web_api/products/", function(data) {
$('.modal').modal('show');
var imgWS = data.Products[key].Product.ProductImage[0].http;
var nomeWS = data.Products[key].Product.name;
nomeWS.toString();
nomeWS.substr(1, 5);
console.log(nomeWS);
var precoWS = data.Products[key].Product.promotional_price;
console.log(precoWS);
//var quantidadeWS = document.getElementById("quantidade").value;
var output2='<div class="add-product">';
output2+='<img src="' + imgWS + '" />';
output2+='<p class="nome">' + nomeWS + '</p>';
output2+='<p class="preco-antigo">' + precoWS + '</p>';
output2+='<p><input type= "text" id="quantidade" name="quantidade" class="form-control text-center" placeholder="Digite a quantidade"></p>';
output2+='<p><button type="button" class="btn btn-success" data-dismiss="modal" onclick="saveListWS(' + nomeWS +')">Comprar</button></p>';
output2+='</div>';
document.getElementById("modal-body").innerHTML = output2;
//$('.modal-body').html(output2);
});
}